-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.ts
127 lines (125 loc) · 3.36 KB
/
astro.config.ts
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
122
123
124
125
126
127
import mdx from "@astrojs/mdx"
import solid from "@astrojs/solid-js"
import tailwind from "@astrojs/tailwind"
import {
type Options as RemarkCalloutOptions,
remarkCallout,
} from "@r4ai/remark-callout"
import remarkEmbed, { type RemarkEmbedOptions } from "@r4ai/remark-embed"
import {
transformerLinkCard,
type TransformerLinkCardOptions,
} from "@r4ai/remark-embed/transformers"
import {
transformerMetaHighlight,
transformerMetaWordHighlight,
transformerNotationDiff,
transformerNotationHighlight,
transformerNotationWordHighlight,
} from "@shikijs/transformers"
import { defineConfig } from "astro/config"
import rehypeKatex from "rehype-katex"
import remarkMath from "remark-math"
import { visualizer } from "rollup-plugin-visualizer"
import icons from "unplugin-icons/vite"
import {
transformerLineNumbers,
transformerMetaDiff,
transformerTitle,
} from "./src/lib/shiki-transformers"
import remarkInlineCode from "./src/lib/unified-plugins/remark-inline-code"
import pagefind from "./src/lib/vite-plugins/vite-plugin-pagefind"
import rawTransform from "./src/lib/vite-plugins/vite-plugin-raw-transform"
// https://astro.build/config
export default defineConfig({
site: "https://r4ai.dev",
prefetch: true,
integrations: [
tailwind({
applyBaseStyles: false,
}),
mdx(),
solid(),
],
redirects: {
"/posts/raw/[...slug]": "/posts/[...slug].mdx",
"/posts/[...slug]/raw": "/posts/[...slug].mdx",
},
vite: {
plugins: [
pagefind(),
rawTransform(),
icons({ compiler: "solid" }),
visualizer({
emitFile: true,
filename: "stats.html",
}),
],
},
markdown: {
remarkPlugins: [
remarkMath,
remarkInlineCode,
[
remarkEmbed,
{
transformers: [
transformerLinkCard({
tagName: () => "link-card",
properties: (og) => ({ og: JSON.stringify(og) }),
children: () => [],
} satisfies TransformerLinkCardOptions),
],
} satisfies RemarkEmbedOptions,
],
[
remarkCallout,
{
root: (callout) => {
return {
tagName: "callout-root",
properties: {
type: callout.type,
isFoldable: callout.isFoldable.toString(),
defaultFolded: callout.defaultFolded?.toString(),
},
}
},
title: (callout) => ({
tagName: "callout-title",
properties: {
type: callout.type,
isFoldable: callout.isFoldable.toString(),
},
}),
body: () => ({
tagName: "callout-body",
properties: {},
}),
} satisfies RemarkCalloutOptions,
],
],
rehypePlugins: [rehypeKatex],
remarkRehype: {
footnoteLabel: "脚注",
footnoteLabelTagName: "h2",
footnoteLabelProperties: {},
},
shikiConfig: {
themes: {
light: "github-light",
dark: "one-dark-pro",
},
transformers: [
transformerMetaDiff(),
transformerMetaHighlight(),
transformerMetaWordHighlight(),
transformerNotationDiff(),
transformerNotationHighlight(),
transformerNotationWordHighlight(),
transformerLineNumbers(),
transformerTitle(),
],
},
},
})