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,6 +25,11 @@ export default defineConfig({
4625 src : "./src/assets/logo.png" ,
4726 replacesTitle : true ,
4827 } ,
28+ //自定义组件
29+ components : {
30+ //重写主题提供组件,实现默认深色主题
31+ ThemeProvider : "./src/components/ThemeProvider.astro" ,
32+ } ,
4933 disable404Route : true ,
5034 social : {
5135 github : "https://github.com/Serverless-Devs/Serverless-Devs" ,
@@ -56,6 +40,7 @@ export default defineConfig({
5640 editLink : {
5741 baseUrl : SITE . websiteGithubUrl ,
5842 } ,
43+ //多路侧边栏设置
5944 sidebar : SIDEBAR ,
6045 plugins : [
6146 starlightUtils ( {
@@ -64,41 +49,14 @@ export default defineConfig({
6449 } ,
6550 } ) ,
6651 ] ,
67- // locales,
68- // customCss: ['./src/style/global.css','./src/style/fonts.css'],
6952 } ) ,
7053 tailwind ( { applyBaseStyles : false } ) ,
7154 icon ( {
7255 tabler : [ "book" , "pencil" ] ,
7356 "ant-design" : [ "github-filled" ] ,
7457 basil : [ "document-outline" ] ,
7558 } ) ,
76- preact ( { compat : true } ) ,
77- ...whenExternalScripts ( ( ) =>
78- partytown ( {
79- config : { forward : [ "dataLayer.push" ] } ,
80- } ) ,
81- ) ,
8259 ] ,
83- markdown : {
84- rehypePlugins : [
85- // 在这里添加 rehype-external-links 插件配置
86- [
87- rehypeExternalLinks ,
88- {
89- target : "_blank" ,
90- } ,
91- ] ,
92- ] ,
93- remarkPlugins : [
94- remarkRemoveMdLinks ,
95- remarkRemovePlainLanguageCode ,
96- remarkRemoveRepeatHeader ,
97- addPrefixImageLink ,
98- starlightAsides ,
99- setLinkReferrer ,
100- ] ,
101- } ,
10260 vite : {
10361 build : {
10462 target : "chrome68" ,
0 commit comments