1
1
import { defineConfig } from "astro/config" ;
2
2
import starlight from "@astrojs/starlight" ;
3
- import partytown from "@astrojs/partytown" ;
4
- import preact from "@astrojs/preact" ;
5
3
import { autoImportComponents } from "@serverless-cd/goat-ui/src/utils" ;
6
4
import tailwind from "@astrojs/tailwind" ;
7
5
import 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" ;
20
7
import topLevelAwait from "vite-plugin-top-level-await" ;
21
8
import starlightUtils from "@lorenzo_lewis/starlight-utils" ;
22
9
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
-
31
10
// https://astro.build/config
32
11
export default defineConfig ( {
33
12
site : process . env . DEPLOY_SITE || SITE . site ,
34
13
base : SITE . base ,
14
+ //设置处理后斜杠的策略
35
15
trailingSlash : SITE . trailingSlash ,
36
16
image : {
37
17
domain : [ "img.alicdn" ] ,
38
18
} ,
39
-
40
19
integrations : [
41
20
autoImportComponents ( ) ,
42
21
starlight ( {
@@ -46,7 +25,9 @@ export default defineConfig({
46
25
src : "./src/assets/logo.png" ,
47
26
replacesTitle : true ,
48
27
} ,
28
+ //自定义组件
49
29
components : {
30
+ //重写主题提供组件,实现默认深色主题
50
31
ThemeProvider : "./src/components/ThemeProvider.astro" ,
51
32
} ,
52
33
disable404Route : true ,
@@ -59,6 +40,7 @@ export default defineConfig({
59
40
editLink : {
60
41
baseUrl : SITE . websiteGithubUrl ,
61
42
} ,
43
+ //多路侧边栏设置
62
44
sidebar : SIDEBAR ,
63
45
plugins : [
64
46
starlightUtils ( {
@@ -74,32 +56,7 @@ export default defineConfig({
74
56
"ant-design" : [ "github-filled" ] ,
75
57
basil : [ "document-outline" ] ,
76
58
} ) ,
77
- preact ( { compat : true } ) ,
78
- ...whenExternalScripts ( ( ) =>
79
- partytown ( {
80
- config : { forward : [ "dataLayer.push" ] } ,
81
- } ) ,
82
- ) ,
83
59
] ,
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
- } ,
103
60
vite : {
104
61
build : {
105
62
target : "chrome68" ,
0 commit comments