forked from EveSunMaple/Frosti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathastro.config.mjs
110 lines (108 loc) · 3.33 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
import { defineConfig } from 'astro/config';
import mdx from '@astrojs/mdx';
import sitemap from '@astrojs/sitemap';
import tailwind from "@astrojs/tailwind";
import remarkMath from 'remark-math';
import rehypeKatex from 'rehype-katex';
import playformCompress from "@playform/compress";
import vercel from '@astrojs/vercel/static';
import pagefind from "astro-pagefind";
import icon from "astro-icon";
// https://astro.build/config
export default defineConfig({
site: 'https://frosti.saroprock.com',
output: 'static',
adapter: vercel({
webAnalytics: { enabled: true }
}),
style: {
scss: {
includePaths: ['./src/styles']
}
},
integrations: [mdx(), icon(), sitemap(), tailwind(), playformCompress(), pagefind()],
markdown: {
shikiConfig: {
themes: {
light: 'github-light',
dark: 'github-dark',
},
transformers: [
{
preprocess(code, { lang }) {
this.lang = lang;
return code;
},
root(node) {
if (node.tagName === 'pre') {
node.tagName = 'figure';
node.properties.className = ['highlight', this.lang];
}
},
pre(node) {
const toolsDiv = {
type: 'element',
tagName: 'div',
properties: { className: ['highlight-tools'] },
children: [
{
type: 'element',
tagName: 'div',
properties: { className: ['code-lang'] },
children: [{ type: 'text', value: this.lang.toUpperCase() }],
},
],
};
const lineNumberCode = {
type: 'element',
tagName: 'code',
children: [],
};
const lineNumberPre = {
type: 'element',
tagName: 'pre',
properties: { className: ['frosti-code', 'gutter'] },
children: [lineNumberCode],
};
const codeContentPre = {
type: 'element',
tagName: 'pre',
properties: { className: ['frosti-code', 'code'] },
children: [],
};
node.children.forEach((lineNode, index, count) => {
count = 0;
lineNode.children.forEach(() => {
if (count & 1 === 1) {
lineNumberCode.children.push({
type: 'element',
tagName: 'div',
properties: { className: ['line'] },
children: [{ type: 'text', value: String(index + 1) }],
});
index++;
}
count++;
});
codeContentPre.children.push(lineNode);
});
const table = {
type: 'element',
tagName: 'div',
properties: { className: ['highlight-code'] },
children: [lineNumberPre, codeContentPre],
};
return {
type: 'element',
tagName: 'figure',
properties: { className: ['highlight', this.lang] },
children: [toolsDiv, table],
};
},
},
],
},
remarkPlugins: [remarkMath],
rehypePlugins: [rehypeKatex]
},
});