2025-02-24 16:18:36 +08:00
|
|
|
|
// @ts-check
|
2025-03-28 22:14:16 +08:00
|
|
|
|
import { defineConfig } from "astro/config";
|
2025-02-24 16:18:36 +08:00
|
|
|
|
|
2025-03-28 22:14:16 +08:00
|
|
|
|
import tailwindcss from "@tailwindcss/vite";
|
|
|
|
|
import mdx from "@astrojs/mdx";
|
|
|
|
|
import react from "@astrojs/react";
|
|
|
|
|
import rehypeExternalLinks from "rehype-external-links";
|
|
|
|
|
import { SITE_URL } from "./src/consts";
|
2025-04-25 00:01:44 +08:00
|
|
|
|
import compressor from "astro-compressor";
|
2025-03-28 22:14:16 +08:00
|
|
|
|
import vercel from "@astrojs/vercel";
|
2025-05-02 23:47:55 +08:00
|
|
|
|
import { articleIndexerIntegration } from "./src/plugins/build-article-index.js";
|
2025-05-04 03:44:10 +08:00
|
|
|
|
import { rehypeCodeBlocks } from "./src/plugins/rehype-code-blocks.js";
|
2025-05-08 09:46:43 +08:00
|
|
|
|
import { rehypeTables } from "./src/plugins/rehype-tables.js";
|
2025-05-18 22:24:26 +08:00
|
|
|
|
import { customSitemapIntegration } from "./src/plugins/sitemap-integration.js";
|
2025-03-03 21:16:16 +08:00
|
|
|
|
|
2025-02-24 16:18:36 +08:00
|
|
|
|
// https://astro.build/config
|
2025-03-03 21:16:16 +08:00
|
|
|
|
export default defineConfig({
|
2025-03-09 14:37:44 +08:00
|
|
|
|
site: SITE_URL,
|
2025-03-28 22:14:16 +08:00
|
|
|
|
output: "static",
|
|
|
|
|
trailingSlash: "ignore",
|
2025-03-09 14:37:44 +08:00
|
|
|
|
|
2025-03-08 18:16:42 +08:00
|
|
|
|
build: {
|
2025-03-28 22:14:16 +08:00
|
|
|
|
format: "directory",
|
2025-03-08 18:16:42 +08:00
|
|
|
|
},
|
2025-03-09 14:37:44 +08:00
|
|
|
|
|
2025-03-03 21:16:16 +08:00
|
|
|
|
vite: {
|
2025-03-09 01:11:43 +08:00
|
|
|
|
plugins: [tailwindcss()],
|
2025-03-03 21:16:16 +08:00
|
|
|
|
},
|
|
|
|
|
|
2025-03-08 18:16:42 +08:00
|
|
|
|
integrations: [
|
2025-05-03 19:50:03 +08:00
|
|
|
|
// 使用Astro官方的MDX支持
|
2025-04-25 00:01:44 +08:00
|
|
|
|
mdx(),
|
2025-03-08 18:16:42 +08:00
|
|
|
|
react(),
|
2025-05-03 19:50:03 +08:00
|
|
|
|
// 使用文章索引生成器
|
2025-05-02 23:47:55 +08:00
|
|
|
|
articleIndexerIntegration(),
|
2025-05-18 22:24:26 +08:00
|
|
|
|
customSitemapIntegration(),
|
2025-04-25 00:01:44 +08:00
|
|
|
|
// 添加压缩插件 (必须放在最后位置)
|
|
|
|
|
compressor()
|
2025-03-08 18:16:42 +08:00
|
|
|
|
],
|
2025-03-09 14:37:44 +08:00
|
|
|
|
|
2025-05-03 19:50:03 +08:00
|
|
|
|
// Markdown 配置 - 使用官方语法高亮
|
2025-03-03 21:16:16 +08:00
|
|
|
|
markdown: {
|
2025-05-03 19:50:03 +08:00
|
|
|
|
// 配置语法高亮
|
|
|
|
|
syntaxHighlight: {
|
|
|
|
|
// 使用shiki作为高亮器
|
|
|
|
|
type: 'shiki',
|
|
|
|
|
// 排除mermaid语言,不进行高亮处理
|
|
|
|
|
excludeLangs: ['mermaid']
|
|
|
|
|
},
|
|
|
|
|
// Shiki主题配置
|
|
|
|
|
shikiConfig: {
|
2025-05-04 03:44:10 +08:00
|
|
|
|
// 默认主题 - 必须设置,但最终会被替换为 light/dark 主题
|
2025-05-03 19:50:03 +08:00
|
|
|
|
theme: 'github-light',
|
2025-05-04 03:44:10 +08:00
|
|
|
|
// 定义明亮和暗黑主题
|
2025-05-03 19:50:03 +08:00
|
|
|
|
themes: {
|
|
|
|
|
light: 'github-light',
|
|
|
|
|
dark: 'github-dark'
|
|
|
|
|
},
|
2025-05-04 03:44:10 +08:00
|
|
|
|
// 启用代码换行
|
2025-05-03 19:50:03 +08:00
|
|
|
|
wrap: true
|
|
|
|
|
},
|
2025-03-03 21:16:16 +08:00
|
|
|
|
rehypePlugins: [
|
2025-05-04 03:44:10 +08:00
|
|
|
|
[rehypeExternalLinks, { target: '_blank', rel: ['nofollow', 'noopener', 'noreferrer'] }],
|
2025-05-08 09:46:43 +08:00
|
|
|
|
rehypeCodeBlocks,
|
|
|
|
|
rehypeTables
|
2025-03-03 21:16:16 +08:00
|
|
|
|
],
|
2025-03-10 15:15:30 +08:00
|
|
|
|
gfm: true,
|
2025-03-09 14:37:44 +08:00
|
|
|
|
},
|
|
|
|
|
|
2025-03-28 22:14:16 +08:00
|
|
|
|
adapter: vercel(),
|
|
|
|
|
});
|