|
1 | | -import { defineConfig } from 'vitepress'; |
2 | | -import type { DefaultTheme } from 'vitepress'; |
3 | | -import imagePlugin from './markdown/imagePlugin'; |
4 | | -import { getPosts } from './theme/serverUtils'; |
| 1 | +import type { DefaultTheme } from 'vitepress' |
| 2 | +import { globby } from 'globby' |
| 3 | +import { defineConfig } from 'vitepress' |
| 4 | +import { generatePaginationPages } from './data/post.data.ts' |
| 5 | +import imagePlugin from './markdown/imagePlugin' |
5 | 6 |
|
6 | | -const navize = 10; |
7 | | - |
8 | | -export default defineConfig({ |
9 | | - title: '幺幺零玖', |
10 | | - description: 'A VitePress Site', |
11 | | - themeConfig: { |
12 | | - outline: { |
13 | | - label: '页面导航', |
14 | | - // level: [2, 3], |
15 | | - }, |
16 | | - posts: await getPosts(navize), |
17 | | - nav: [ |
18 | | - { text: '首页', link: '/' }, |
19 | | - { text: '分类', link: '/nav/category' }, |
20 | | - { text: '标签', link: '/nav/tags' }, |
21 | | - { text: '历史', link: '/nav/archives' }, |
22 | | - { |
23 | | - text: '基础知识', |
24 | | - items: [ |
25 | | - { text: '设计', link: '/frontend/design' }, |
26 | | - { text: '浏览器', link: '/frontend/browser' }, |
27 | | - { text: 'html', link: '/frontend/html' }, |
28 | | - { text: 'css', link: '/frontend/css' }, |
29 | | - { text: 'javaScript', link: '/frontend/javaScript' }, |
30 | | - { text: 'vue', link: '/frontend/vue' }, |
31 | | - ], |
| 7 | +export default async () => { |
| 8 | + const posts = await globby(['posts/**.md']) |
| 9 | + await generatePaginationPages(posts.length, 10) |
| 10 | + return defineConfig({ |
| 11 | + title: '零玖', |
| 12 | + description: 'A VitePress Site', |
| 13 | + themeConfig: { |
| 14 | + outline: { |
| 15 | + label: '导航', |
| 16 | + // level: [2, 3], |
| 17 | + }, |
| 18 | + nav: [ |
| 19 | + { text: '首页', link: '/' }, |
| 20 | + { |
| 21 | + text: '文章', |
| 22 | + items: [ |
| 23 | + { text: '历史', link: '/nav/archives' }, |
| 24 | + { text: '分类', link: '/nav/category' }, |
| 25 | + { text: '标签', link: '/nav/tags' }, |
| 26 | + ], |
| 27 | + }, |
| 28 | + { |
| 29 | + text: '基础知识', |
| 30 | + items: [ |
| 31 | + { text: '设计', link: '/frontend/design' }, |
| 32 | + { text: '浏览器', link: '/frontend/browser' }, |
| 33 | + { text: 'html', link: '/frontend/html' }, |
| 34 | + { text: 'css', link: '/frontend/css' }, |
| 35 | + { text: 'javaScript', link: '/frontend/javaScript' }, |
| 36 | + { text: 'vue', link: '/frontend/vue' }, |
| 37 | + ], |
| 38 | + }, |
| 39 | + { |
| 40 | + text: '导航', |
| 41 | + items: [ |
| 42 | + { text: '工具', link: '/frontend/nav/tool' }, |
| 43 | + { text: '镜像', link: '/frontend/nav/mirrors' }, |
| 44 | + ], |
| 45 | + }, |
| 46 | + { text: '关于', link: '/nav/about' }, |
| 47 | + ], |
| 48 | + search: { |
| 49 | + provider: 'local', |
| 50 | + }, |
| 51 | + socialLinks: [ |
| 52 | + { |
| 53 | + icon: 'github', |
| 54 | + link: 'https://github.com/vuejs/vitepress', |
| 55 | + }, |
| 56 | + ], |
| 57 | + } as DefaultTheme.Config, |
| 58 | + markdown: { |
| 59 | + config: (md) => { |
| 60 | + md.use(imagePlugin as any) |
32 | 61 | }, |
33 | | - { text: '前端导航', link: '/frontend/nav' }, |
34 | | - { text: '关于', link: '/nav/about' }, |
35 | | - ], |
36 | | - search: { |
37 | | - provider: 'local', |
38 | | - }, |
39 | | - socialLinks: [ |
40 | | - { icon: 'github', link: 'https://github.com/vuejs/vitepress' }, |
41 | | - ], |
42 | | - } as DefaultTheme.Config, |
43 | | - markdown: { |
44 | | - config: (md) => { |
45 | | - md.use(imagePlugin as any); |
46 | 62 | }, |
47 | | - }, |
48 | | -}); |
| 63 | + }) |
| 64 | +} |
0 commit comments