mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-12-20 09:45:38 +08:00
chore: 调整代码执行细节
This commit is contained in:
16
docs/.vitepress/scripts/indexArticleSidebar.ts
Normal file
16
docs/.vitepress/scripts/indexArticleSidebar.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
/**
|
||||
* 生成文章侧边栏
|
||||
*/
|
||||
export function indexArticleSidebar() {
|
||||
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
||||
|
||||
return articles
|
||||
.filter((article) => article.endsWith('.md'))
|
||||
.map((article) => ({
|
||||
text: article.replace(/\.md$/, ''),
|
||||
link: `/article/${article}`
|
||||
}))
|
||||
}
|
||||
Reference in New Issue
Block a user