预处理 在页面的 frontmatter 中注入文件的 Git 时间戳
依赖
- vitepress
- ./get-file-git-timestamps
权限
- 读文件
- 执行命令
介绍
在预处理阶段 在页面的 frontmatter 中注入文件的 Git 时间戳
没有 frontmatter 将会添加 frontmatter
使用
ts
// .vitepress/config.mts
// 示例
import prePageFrontmatterInjectionTimestamp from './plugins/<dir>/vitepress-plugin-pre-page-frontmatter-injection-timestamp.ts'
export default defineConfig({
vite: {
plugins: [
prePageFrontmatterInjectionTimestamp({
fileExtensionArray: ['.md']
})
]
}
})1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
效果
yaml
---
layout: home
hero:
name: "doc.md"
---1
2
3
4
5
2
3
4
5
↓
yaml
---
layout: home
hero:
name: "doc.md"
myGitArticleData:
createTime: 3376656000
updateTime: 3376656000
editCount: 6
---1
2
3
4
5
6
7
8
9
2
3
4
5
6
7
8
9
注意事项
无