全局配置
ts
// .vitepress/config.mts
import { defineConfig } from 'vitepress'
import { getPosts } from '@theojs/solis/utils'
const posts = { posts: await getPosts(6) } //代表一页有6篇文章
export default defineConfig({
themeConfig: {
...posts,
nav: [
{ text: '主页', link: '/' },
{ text: '分类', link: '/pages/category' },
{ text: '归档', link: '/pages/archives' },
{ text: '标签', link: '/pages/tags' }
]
}
...
})
注册页面布局组件
ts
// .vitepress/theme/index.ts
import DefaultTheme from 'vitepress/theme'
import { Archives, Category, Tags, Page } from '@theojs/solis'
export default {
...
enhanceApp: ({ app }) => {
app.component('Tags', Tags)
app.component('Category', Category)
app.component('Archives', Archives)
app.component('Page', Page)
}
}