-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
81 lines (76 loc) · 2.1 KB
/
vite.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
import { resolve } from 'path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import Unocss from 'unocss/vite'
import type { ReactRoute } from 'vite-plugin-pages'
import Pages from 'vite-plugin-pages'
import Markdown from '@pity/vite-plugin-react-markdown'
import Shiki from 'markdown-it-shiki'
import anchor from 'markdown-it-anchor'
import TOC from 'markdown-it-table-of-contents'
import LinkAttributes from 'markdown-it-link-attributes'
import Katex from 'markdown-it-katex'
import TaskList from 'markdown-it-task-lists'
// import { imgLazyload } from '@mdit/plugin-img-lazyload'
import { attrs } from '@mdit/plugin-attrs'
import { slugify, useMdRouter } from './config'
export default defineConfig({
plugins: [
Unocss(),
react(),
Pages({
exclude: [
'src/views/page/pageComponents/*.tsx',
],
dirs: [
{ dir: 'src/views', baseRoute: '' },
{ dir: 'pages', baseRoute: '' },
],
extensions: ['tsx', 'md'],
extendRoute(route: ReactRoute) {
const { mdRoute } = useMdRouter(route)
return mdRoute
},
}),
Markdown({
wrapperClasses: 'prose m-auto',
wrapperComponentName: 'ReactMarkdown',
wrapperComponentPath: './src/components/page',
markdownItSetup(md) {
md.use(Shiki, {
theme: {
light: 'vitesse-light',
dark: 'vitesse-dark',
},
})
md.use(anchor, {
slugify,
permalink: anchor.permalink.linkInsideHeader({
symbol: '#',
renderAttrs: () => ({ 'aria-hidden': 'true' }),
}),
})
md.use(LinkAttributes, {
matcher: (link: string) => /^https?:\/\//.test(link),
attrs: {
target: '_blank',
rel: 'noopener',
},
})
md.use(TOC, {
includeLevel: [1, 2, 3],
slugify,
})
md.use(Katex)
md.use(TaskList)
md.use(attrs)
},
}),
],
resolve: {
alias: {
'@': resolve(__dirname, 'src'),
'#': resolve(__dirname, 'types'),
},
},
})