-
Notifications
You must be signed in to change notification settings - Fork 59
/
astro.config.mjs
121 lines (116 loc) · 3.67 KB
/
astro.config.mjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { defineConfig } from 'astro/config';
import sitemap from '@astrojs/sitemap';
import starlight from '@astrojs/starlight';
import partytown from '@astrojs/partytown';
import preact from "@astrojs/preact";
import { autoImportComponents } from "@serverless-cd/goat-ui/src/utils";
import locales from './src/i18n/languages';
import tailwind from "@astrojs/tailwind";
import icon from "astro-icon";
// import compress from 'astro-compress';
import rehypeExternalLinks from 'rehype-external-links'
import { remarkRemoveMdLinks, remarkRemovePlainLanguageCode, remarkRemoveRepeatHeader, addPrefixImageLink, setLinkReferrer } from './src/utils/frontmatter.mjs';
import { ANALYTICS, SITE } from './src/utils/config.ts';
import goatConfig from './goat.config';
import { starlightAsides } from './node_modules/@astrojs/starlight/integrations/asides';
import topLevelAwait from "vite-plugin-top-level-await";
import icon from 'astro-icon';
const whenExternalScripts = (items = []) =>
ANALYTICS.vendors.googleAnalytics.id && ANALYTICS.vendors.googleAnalytics.partytown
? Array.isArray(items)
? items.map((item) => item())
: [items()]
: [];
// https://astro.build/config
export default defineConfig({
site: process.env.DEPLOY_SITE || SITE.site,
base: SITE.base,
trailingSlash: SITE.trailingSlash,
image: {
domain: ["img.alicdn"]
},
integrations: [
starlight({
title: SITE.name,
favicon:"/higress_logo.png",
social: {
github: 'https://github.com/withastro/starlight'
},
expressiveCode: {
themes: ['github-dark'], //TODO: 待调研
},
components: {
TableOfContents: './src/components/starlight/TableOfContents/index.astro',
Header: './src/components/starlight/Header.astro',
Head: './src/components/starlight/Head.astro',
Sidebar: './src/components/starlight/Sidebar.astro',
PageFrame: "./src/components/starlight/PageFrame.astro",
SkipLink: "./src/components/starlight/SkipLink.astro",
TwoColumnContent: "./src/components/starlight/TwoColumnContent.astro",
PageSidebar: "./src/components/starlight/PageSidebar.astro",
PageTitle: "./src/components/starlight/PageTitle.astro",
ContentPanel: "./src/components/starlight/ContentPanel.astro",
Pagination: "./src/components/starlight/Pagination.astro",
Banner: "./src/components/starlight/Banner.astro",
},
editLink: {
baseUrl: SITE.websiteGithubUrl,
},
locales,
customCss: ['./src/style/global.css','./src/style/fonts.css'],
}),
autoImportComponents(),
tailwind({ applyBaseStyles: false }),
icon({
tabler: ['book', 'pencil'],
'ant-design':['github-filled'],
basil:['document-outline']
}),
preact({ compat: true }),
{
name: '@goat:config',
hooks: {
"astro:server:setup": async (options) => {
await goatConfig();
},
"astro:build:setup": async (options) => {
await goatConfig();
}
}
},
...whenExternalScripts(() =>
partytown({
config: { forward: ['dataLayer.push'] },
})
),
],
markdown: {
rehypePlugins: [
// 在这里添加 rehype-external-links 插件配置
[rehypeExternalLinks, {
target: '_blank'
}]],
remarkPlugins: [
remarkRemoveMdLinks,
remarkRemovePlainLanguageCode,
remarkRemoveRepeatHeader,
addPrefixImageLink,
starlightAsides,
setLinkReferrer
]
},
vite: {
build: {
target: "chrome68",
},
plugins: [topLevelAwait()],
},
// TODO: 梳理redirects
redirects: {
'/zh-cn/': '/',
'/en-us/': '/en/',
'/docs/': '/docs/latest/overview/what-is-higress/',
'/docs/latest/dev/CustomResourceDefinition/': '/docs/latest/dev/customresourcedefinition/',
'/en-us/docs/latest/dev/CustomResourceDefinition/': '/en/docs/latest/dev/customresourcedefinition/',
}
});