usePosts
usePosts 配置项作用于文章列表的生成,例如每页文章数、文章文件夹路径等。
示例代码
ts
// .vitepress/config.ts
const { posts, rewrites } = await usePosts({
pageSize = 10,
homepage = true,
srcDir = 'posts',
outDir = '',
lang = 'zh',
autoExcerpt = 0,
prev = true,
next = true,
slot = '',
custom = ''
});配置项
| 参数名 | 默认值 | 备注 |
|---|---|---|
| pageSize | 10 | 每页文章数 |
| homepage | true | 是否将文章列表设置为主页 |
| srcDir | posts | 文章文件夹 |
| outDir | / | 文章列表、分类页 / 标签页 / 归档页输出路径 |
| lang | zh | 语言 |
| autoExcerpt | 0 | 自动摘要,值为摘要字数 |
| prev | true | 上一页 |
| next | true | 下一页 |
| slot | / | 文章列表页插槽,支持 doc-before 与 doc-after |
| custom | / | 文章列表页自定义代码 |







