-
-
Notifications
You must be signed in to change notification settings - Fork 195
Expand file tree
/
Copy pathastro.config.ts
More file actions
112 lines (109 loc) · 3.02 KB
/
Copy pathastro.config.ts
File metadata and controls
112 lines (109 loc) · 3.02 KB
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
import mdx from '@astrojs/mdx'
import partytown from '@astrojs/partytown'
import sitemap from '@astrojs/sitemap'
import Compress from 'astro-compress'
import { defineConfig } from 'astro/config'
import rehypeKatex from 'rehype-katex'
import rehypeMermaid from 'rehype-mermaid'
import rehypeSlug from 'rehype-slug'
import remarkDirective from 'remark-directive'
import remarkMath from 'remark-math'
import UnoCSS from 'unocss/astro'
import { base, defaultLocale, themeConfig } from './src/config'
import { langMap } from './src/i18n/config'
import { rehypeCodeCopyButton } from './src/plugins/rehype-code-copy-button.mjs'
import { rehypeExternalLinks } from './src/plugins/rehype-external-links.mjs'
import { rehypeHeadingAnchor } from './src/plugins/rehype-heading-anchor.mjs'
import { rehypeImageProcessor } from './src/plugins/rehype-image-processor.mjs'
import { remarkContainerDirectives } from './src/plugins/remark-container-directives.mjs'
import { remarkLeafDirectives } from './src/plugins/remark-leaf-directives.mjs'
import { remarkReadingTime } from './src/plugins/remark-reading-time.mjs'
const { url: site } = themeConfig.site
const { imageHostURL } = themeConfig.preload ?? {}
const imageConfig = imageHostURL
? { image: { domains: [imageHostURL], remotePatterns: [{ protocol: 'https' }] } }
: {}
export default defineConfig({
site,
base,
trailingSlash: 'always', // Not recommended to change
prefetch: {
prefetchAll: true,
defaultStrategy: 'viewport', // hover, tap, viewport, load
},
...imageConfig,
i18n: {
locales: Object.entries(langMap).map(([path, codes]) => ({
path,
codes: [...codes] as [string, ...string[]],
})),
defaultLocale,
},
integrations: [
UnoCSS({
injectReset: true,
}),
mdx(),
partytown({
config: {
forward: ['dataLayer.push', 'gtag'],
},
}),
sitemap(),
Compress({
CSS: true,
HTML: true,
Image: false,
JavaScript: true,
SVG: false,
}),
],
markdown: {
remarkPlugins: [
remarkDirective,
remarkMath,
remarkContainerDirectives,
remarkLeafDirectives,
remarkReadingTime,
],
rehypePlugins: [
rehypeKatex,
[rehypeMermaid, { strategy: 'pre-mermaid' }],
rehypeSlug,
rehypeHeadingAnchor,
rehypeImageProcessor,
rehypeExternalLinks,
rehypeCodeCopyButton,
],
syntaxHighlight: {
type: 'shiki',
excludeLangs: ['mermaid'],
},
shikiConfig: {
// Available themes: https://shiki.style/themes
themes: {
light: 'github-light',
dark: 'github-dark',
},
},
},
vite: {
plugins: [
{
name: 'prefix-font-urls-with-base',
transform(code, id) {
if (!id.split('?')[0].endsWith('src/styles/font.css')) {
return null
}
return code.replace(/url\(\s*(['"]?)\/fonts\//g, `url($1${base}/fonts/`)
},
},
],
build: {
chunkSizeWarningLimit: 600,
},
},
devToolbar: {
enabled: false,
},
})