import type { DefaultTheme, UserConfig } from 'vitepress' import fg from 'fast-glob' import fs from 'fs' import { basename, join, resolve } from 'path' import { mdPlugin } from './plugins' const DIR_GUIDE = resolve(__dirname, '../../guide') const EXCLUDE_PAGE = ['index.md', 'log.md', 'started.md', 'options.md'] const guides = fg.sync('*.md', { cwd: DIR_GUIDE }).filter((i) => !EXCLUDE_PAGE.includes(i)) const components = guides.map((file) => { const firstLine = fs.readFileSync(join(DIR_GUIDE, file)).toString().split(/\n/)[0] const text = firstLine.split(/#+/)[1].trim() const link = `/guide/${basename(file, '.md')}` return { text, link } }) export const config: UserConfig = { title: 'DataGo-Vue-UI-文档', head: [['link', { rel: 'icon', href: 'favicon.ico' }]], themeConfig: { nav: [ { text: '指南', link: '/' }, { text: '更新日志', link: '/guide/log' }, { text: 'GitLab', link: 'http://datago.vicp.hk:50005/datago/datago-vue' }, ], sidebar: [ { text: '介绍', link: '/guide/', }, { text: '快速上手', link: '/guide/started', }, { text: '配置', link: '/guide/options', }, { text: '更新日志', link: '/guide/log', }, { text: '组件', collapsable: false, children: components, }, ], }, markdown: { lineNumbers: false, // config: (md) => mdPlugin(md), }, }