1- import { defineConfig } from 'astro/config' ;
2- import sitemap from '@astrojs/sitemap' ;
3- import starlight from '@astrojs/starlight' ;
4- import partytown from '@astrojs/partytown' ;
1+ import { defineConfig } from "astro/config" ;
2+ import starlight from "@astrojs/starlight" ;
3+ import partytown from "@astrojs/partytown" ;
54import preact from "@astrojs/preact" ;
65import { autoImportComponents } from "@serverless-cd/goat-ui/src/utils" ;
7- import locales from './src/i18n/languages' ;
86import tailwind from "@astrojs/tailwind" ;
97import icon from "astro-icon" ;
108// import compress from 'astro-compress';
11- import rehypeExternalLinks from ' rehype-external-links'
9+ import rehypeExternalLinks from " rehype-external-links" ;
1210
13- import { remarkRemoveMdLinks , remarkRemovePlainLanguageCode , remarkRemoveRepeatHeader , addPrefixImageLink , setLinkReferrer } from './src/utils/frontmatter.mjs' ;
14- import { ANALYTICS , SITE } from './src/utils/config.ts' ;
15- import goatConfig from './goat.config' ;
16- import { starlightAsides } from './node_modules/@astrojs/starlight/integrations/asides' ;
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" ;
1720import topLevelAwait from "vite-plugin-top-level-await" ;
18-
19- import icon from 'astro-icon' ;
21+ import starlightUtils from "@lorenzo_lewis/starlight-utils" ;
2022
2123const whenExternalScripts = ( items = [ ] ) =>
22- ANALYTICS . vendors . googleAnalytics . id && ANALYTICS . vendors . googleAnalytics . partytown
24+ ANALYTICS . vendors . googleAnalytics . id &&
25+ ANALYTICS . vendors . googleAnalytics . partytown
2326 ? Array . isArray ( items )
2427 ? items . map ( ( item ) => item ( ) )
2528 : [ items ( ) ]
2629 : [ ] ;
2730
2831// https://astro.build/config
2932export default defineConfig ( {
30- site : process . env . DEPLOY_SITE || SITE . site ,
31- base : SITE . base ,
32- trailingSlash : SITE . trailingSlash ,
33- image : {
34- domain : [ "img.alicdn" ]
35- } ,
33+ site : process . env . DEPLOY_SITE || SITE . site ,
34+ base : SITE . base ,
35+ trailingSlash : SITE . trailingSlash ,
36+ image : {
37+ domain : [ "img.alicdn" ] ,
38+ } ,
3639
37- integrations : [
38- starlight ( {
39- title : SITE . name ,
40- favicon : '/favicon.png' ,
41- social : {
42- github : 'https://github.com/withastro/starlight'
43- } ,
44- expressiveCode : {
45- themes : [ 'github-dark' ] , //TODO: 待调研
46- } ,
47- components : {
48- TableOfContents : './src/components/starlight/TableOfContents/index.astro' ,
49- Header : './src/components/starlight/Header.astro' ,
50- Head : './src/components/starlight/Head.astro' ,
51- Sidebar : './src/components/starlight/Sidebar.astro' ,
52- PageFrame : "./src/components/starlight/PageFrame.astro" ,
53- SkipLink : "./src/components/starlight/SkipLink.astro" ,
54- TwoColumnContent : "./src/components/starlight/TwoColumnContent.astro" ,
55- PageSidebar : "./src/components/starlight/PageSidebar.astro" ,
56- PageTitle : "./src/components/starlight/PageTitle.astro" ,
57- ContentPanel : "./src/components/starlight/ContentPanel.astro" ,
58- Pagination : "./src/components/starlight/Pagination.astro" ,
59- Banner : "./src/components/starlight/Banner.astro" ,
60- } ,
61- editLink : {
62- baseUrl : SITE . websiteGithubUrl ,
63- } ,
64- locales,
65- customCss : [ './src/style/global.css' , './src/style/fonts.css' ] ,
66- } ) ,
67- autoImportComponents ( ) ,
68- tailwind ( { applyBaseStyles : false } ) ,
69- icon ( {
70- tabler : [ 'book' , 'pencil' ] ,
71- 'ant-design' :[ 'github-filled' ] ,
72- basil :[ 'document-outline' ]
73- } ) ,
74- preact ( { compat : true } ) ,
75- {
76- name : '@goat:config' ,
77- hooks : {
78- "astro:server:setup" : async ( options ) => {
79- await goatConfig ( ) ;
80- } ,
81- "astro:build:setup" : async ( options ) => {
82- await goatConfig ( ) ;
83- }
84- }
85- } ,
86- ...whenExternalScripts ( ( ) =>
87- partytown ( {
88- config : { forward : [ 'dataLayer.push' ] } ,
89- } )
90- ) ,
91- ] ,
92- markdown : {
93- rehypePlugins : [
94- // 在这里添加 rehype-external-links 插件配置
95- [ rehypeExternalLinks , {
96- target : '_blank'
97- } ] ] ,
98- remarkPlugins : [
99- remarkRemoveMdLinks ,
100- remarkRemovePlainLanguageCode ,
101- remarkRemoveRepeatHeader ,
102- addPrefixImageLink ,
103- starlightAsides ,
104- setLinkReferrer
105- ]
106- } ,
107- vite : {
108- build : {
109- target : "chrome68" ,
110- } ,
111- plugins : [ topLevelAwait ( ) ] ,
112- } ,
113- // TODO: 梳理redirects
114- redirects : {
115- '/en-us/' : '/en/' ,
116- '/[...slug].html' : '/[...slug]' ,
117- '/docs/' : '/docs/2022/overview/what-is-sca/' ,
118- }
119- } ) ;
40+ integrations : [
41+ autoImportComponents ( ) ,
42+ starlight ( {
43+ title : SITE . name ,
44+ favicon : "/favicon.png" ,
45+ logo : {
46+ src : "./src/assets/logo.png" ,
47+ replacesTitle : true ,
48+ } ,
49+ disable404Route : true ,
50+ social : {
51+ github : "https://github.com/Serverless-Devs/Serverless-Devs" ,
52+ } ,
53+ expressiveCode : {
54+ themes : [ "github-dark" ] , //TODO: 待调研
55+ } ,
56+ editLink : {
57+ baseUrl : SITE . websiteGithubUrl ,
58+ } ,
59+ sidebar : SIDEBAR ,
60+ plugins : [
61+ starlightUtils ( {
62+ multiSidebar : {
63+ switcherStyle : "hidden" ,
64+ } ,
65+ } ) ,
66+ ] ,
67+ // locales,
68+ // customCss: ['./src/style/global.css','./src/style/fonts.css'],
69+ } ) ,
70+ tailwind ( { applyBaseStyles : false } ) ,
71+ icon ( {
72+ tabler : [ "book" , "pencil" ] ,
73+ "ant-design" : [ "github-filled" ] ,
74+ basil : [ "document-outline" ] ,
75+ } ) ,
76+ preact ( { compat : true } ) ,
77+ ...whenExternalScripts ( ( ) =>
78+ partytown ( {
79+ config : { forward : [ "dataLayer.push" ] } ,
80+ } ) ,
81+ ) ,
82+ ] ,
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+ } ,
102+ vite : {
103+ build : {
104+ target : "chrome68" ,
105+ } ,
106+ plugins : [ topLevelAwait ( ) ] ,
107+ } ,
108+ // TODO: 梳理redirects
109+ redirects : {
110+ "/fc/" : "docs/user-guide/aliyun/fc/readme" ,
111+ "/serverless-devs/command/readme.md" : "docs/user-guide/aliyun/#fc3" ,
112+ } ,
113+ } ) ;
0 commit comments