-
Notifications
You must be signed in to change notification settings - Fork 0
/
astro.config.ts
117 lines (116 loc) · 2.92 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
import { rehypeHeadingIds } from "@astrojs/markdown-remark";
import mdx from "@astrojs/mdx";
import preact from "@astrojs/preact";
import sitemap from "@astrojs/sitemap";
import tailwind from "@astrojs/tailwind";
import compress from "astro-compress";
import { defineConfig } from "astro/config";
import { dirname, resolve } from "path";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypePrettyCode from "rehype-pretty-code";
import remarkCollapse from "remark-collapse";
import remarkToc from "remark-toc";
import Icons from "unplugin-icons/vite";
import { fileURLToPath } from "url";
import { remarkReadingTime } from "./src/utils/frontmatter";
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
// https://astro.build/config
export default defineConfig({
site: "https://baka.icu",
markdown: {
syntaxHighlight: false,
shikiConfig: {
theme: "one-dark-pro",
},
remarkPlugins: [
remarkToc,
[
remarkCollapse,
{
test: "Table of contents",
},
],
remarkReadingTime,
],
rehypePlugins: [
rehypeHeadingIds,
[
rehypeAutolinkHeadings,
{
behavior: "append",
properties: {
className: ["heading-anchor"],
},
content: {
type: "text",
value: "\u200B",
},
},
],
[
rehypePrettyCode,
{
theme: "one-dark-pro",
keepBackground: true,
// Callback hooks to add custom logic to nodes when visiting
// them.
onVisitLine(node: { children: string | unknown[] }) {
// Prevent lines from collapsing in `display: grid` mode, and
// allow empty lines to be copy/pasted
if (node.children.length === 0) {
node.children = [
{
type: "text",
value: " ",
},
];
}
},
onVisitHighlightedLine(node: {
properties: {
className: string[];
};
}) {
// Each line node by default has `class="line"`.
node.properties.className.push("highlighted");
},
onVisitHighlightedWord(node: {
properties: {
className: string[];
};
}) {
// Each word node has no className by default.
node.properties.className = ["word"];
},
},
],
],
},
vite: {
resolve: {
alias: {
"@": resolve(__dirname, "./src"),
},
},
plugins: [
Icons({
compiler: "astro",
}),
],
},
integrations: [
mdx(),
sitemap(),
tailwind(),
preact(),
compress({
CSS: true,
HTML: true,
Image: false,
JavaScript: true,
SVG: false,
Logger: 1,
}),
],
});