mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-12-20 01:35:38 +08:00
chore: 调整代码执行细节
This commit is contained in:
@@ -1,19 +0,0 @@
|
||||
import fs from 'fs'
|
||||
import path from 'path'
|
||||
|
||||
export default function generateSideBar() {
|
||||
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
||||
|
||||
const sidebar = articles
|
||||
.filter((article) => article.endsWith('.md'))
|
||||
.map((article) => {
|
||||
// 移除后缀 `.md`
|
||||
const title = article.replace(/\.md$/, '')
|
||||
return {
|
||||
text: title,
|
||||
link: `/article/${title}`
|
||||
}
|
||||
})
|
||||
|
||||
return sidebar
|
||||
}
|
||||
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