yufan.me/astro.config.ts

81 lines
2.5 KiB
TypeScript
Raw Normal View History

2024-06-14 02:11:26 +08:00
import mdx from '@astrojs/mdx';
import zeabur from '@zeabur/astro-adapter/serverless';
import { uploader } from 'astro-uploader';
2024-06-14 02:11:26 +08:00
import { defineConfig, envField } from 'astro/config';
import rehypeAutolinkHeadings from 'rehype-autolink-headings';
import rehypeExternalLinks from 'rehype-external-links';
import rehypeSlug from 'rehype-slug';
import options from './options';
import { astroImage } from './plugins/images';
2024-06-14 02:11:26 +08:00
// https://astro.build/config
export default defineConfig({
// This will override the import.meta.env.SITE. No need to introduce method.
site: options.isProd() ? options.website : options.local.website,
2024-06-14 02:11:26 +08:00
output: 'server',
security: {
checkOrigin: true,
},
image: {
domains: ['localhost', '127.0.0.1'],
service: !options.isProd() ? { entrypoint: './plugins/resize', config: {} } : undefined,
},
2024-06-14 02:11:26 +08:00
experimental: {
contentLayer: true,
contentIntellisense: true,
2024-06-14 02:11:26 +08:00
env: {
schema: {
// Postgres Database
2024-06-14 02:11:26 +08:00
POSTGRES_HOST: envField.string({ context: 'server', access: 'secret' }),
POSTGRES_PORT: envField.number({ context: 'server', access: 'secret' }),
POSTGRES_USERNAME: envField.string({ context: 'server', access: 'secret' }),
POSTGRES_PASSWORD: envField.string({ context: 'server', access: 'secret' }),
POSTGRES_DATABASE: envField.string({ context: 'server', access: 'secret' }),
// Artalk Comment
ARTALK_HOST: envField.string({ context: 'server', access: 'secret' }),
2024-06-14 02:11:26 +08:00
},
2024-07-18 10:30:56 +08:00
validateSecrets: true,
2024-06-14 02:11:26 +08:00
},
},
integrations: [
mdx({
remarkPlugins: [astroImage],
rehypePlugins: [
[rehypeExternalLinks, { rel: 'nofollow', target: '_blank' }],
rehypeSlug,
[rehypeAutolinkHeadings, { behavior: 'append', properties: {} }],
],
2024-06-14 02:11:26 +08:00
}),
uploader({
paths: ['images', 'og', 'cats'],
endpoint: process.env.S3_ENDPOINT,
bucket: process.env.S3_BUCKET as string,
accessKey: process.env.S3_ACCESS_KEY as string,
secretAccessKey: process.env.S3_SECRET_ACCESS_KEY as string,
}),
2024-06-14 02:11:26 +08:00
],
adapter: zeabur(),
2024-06-14 02:11:26 +08:00
markdown: {
gfm: true,
shikiConfig: {
theme: 'solarized-light',
wrap: false,
},
},
server: {
port: options.local.port,
2024-06-14 02:11:26 +08:00
},
devToolbar: {
// I don't need such toolbar.
enabled: false,
},
vite: {
// Add this for avoiding the needless import optimize in Vite.
2024-07-08 22:36:37 +08:00
optimizeDeps: { exclude: ['@napi-rs/canvas', 'opendal'] },
2024-06-14 02:11:26 +08:00
},
build: {
assets: 'cats',
assetsPrefix: options.assetsPrefix(),
},
2024-06-14 02:11:26 +08:00
});