chore: 调整代码执行细节

This commit is contained in:
ZiuChen
2024-04-02 14:24:17 +08:00
parent f0451e0a72
commit a89c4a8d31
5 changed files with 22 additions and 25 deletions

View File

@@ -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
}

View 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}`
}))
}