11import { defineConfig } from "astro/config" ;
22import starlight from "@astrojs/starlight" ;
3- import partytown from "@astrojs/partytown" ;
4- import preact from "@astrojs/preact" ;
53import { autoImportComponents } from "@serverless-cd/goat-ui/src/utils" ;
64import tailwind from "@astrojs/tailwind" ;
75import icon from "astro-icon" ;
8- // import compress from 'astro-compress';
9- import rehypeExternalLinks from "rehype-external-links" ;
10-
11- import {
12- addPrefixImageLink ,
13- remarkRemoveMdLinks ,
14- remarkRemovePlainLanguageCode ,
15- remarkRemoveRepeatHeader ,
16- setLinkReferrer ,
17- } from "./src/utils/frontmatter.mjs" ;
18- import { ANALYTICS , SIDEBAR , SITE } from "./src/utils/config.ts" ;
19- import { starlightAsides } from "./node_modules/@astrojs/starlight/integrations/asides" ;
6+ import { SIDEBAR , SITE } from "./src/utils/config.ts" ;
207import topLevelAwait from "vite-plugin-top-level-await" ;
218import starlightUtils from "@lorenzo_lewis/starlight-utils" ;
229
23- const whenExternalScripts = ( items = [ ] ) =>
24- ANALYTICS . vendors . googleAnalytics . id &&
25- ANALYTICS . vendors . googleAnalytics . partytown
26- ? Array . isArray ( items )
27- ? items . map ( ( item ) => item ( ) )
28- : [ items ( ) ]
29- : [ ] ;
30-
3110// https://astro.build/config
3211export default defineConfig ( {
3312 site : process . env . DEPLOY_SITE || SITE . site ,
3413 base : SITE . base ,
14+ //设置处理后斜杠的策略
3515 trailingSlash : SITE . trailingSlash ,
3616 image : {
3717 domain : [ "img.alicdn" ] ,
3818 } ,
39-
4019 integrations : [
4120 autoImportComponents ( ) ,
4221 starlight ( {
@@ -46,7 +25,9 @@ export default defineConfig({
4625 src : "./src/assets/logo.png" ,
4726 replacesTitle : true ,
4827 } ,
28+ //自定义组件
4929 components : {
30+ //重写主题提供组件,实现默认深色主题
5031 ThemeProvider : "./src/components/ThemeProvider.astro" ,
5132 } ,
5233 disable404Route : true ,
@@ -59,6 +40,7 @@ export default defineConfig({
5940 editLink : {
6041 baseUrl : SITE . websiteGithubUrl ,
6142 } ,
43+ //多路侧边栏设置
6244 sidebar : SIDEBAR ,
6345 plugins : [
6446 starlightUtils ( {
@@ -74,32 +56,7 @@ export default defineConfig({
7456 "ant-design" : [ "github-filled" ] ,
7557 basil : [ "document-outline" ] ,
7658 } ) ,
77- preact ( { compat : true } ) ,
78- ...whenExternalScripts ( ( ) =>
79- partytown ( {
80- config : { forward : [ "dataLayer.push" ] } ,
81- } ) ,
82- ) ,
8359 ] ,
84- markdown : {
85- rehypePlugins : [
86- // 在这里添加 rehype-external-links 插件配置
87- [
88- rehypeExternalLinks ,
89- {
90- target : "_blank" ,
91- } ,
92- ] ,
93- ] ,
94- remarkPlugins : [
95- remarkRemoveMdLinks ,
96- remarkRemovePlainLanguageCode ,
97- remarkRemoveRepeatHeader ,
98- addPrefixImageLink ,
99- starlightAsides ,
100- setLinkReferrer ,
101- ] ,
102- } ,
10360 vite : {
10461 build : {
10562 target : "chrome68" ,
0 commit comments