mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-08-17 23:19:55 +08:00
23 lines
534 B
TypeScript
23 lines
534 B
TypeScript
import fs from 'fs'
|
|
import path from 'path'
|
|
|
|
export default function generateSideBar() {
|
|
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
|
|
|
// 排除掉资源文件夹
|
|
const folders = ['assets']
|
|
|
|
const sidebar = articles
|
|
.filter((article) => !folders.includes(article))
|
|
.map((article) => {
|
|
// 移除后缀 `.md`
|
|
const title = article.replace(/\.md$/, '')
|
|
return {
|
|
text: title,
|
|
link: `/article/${title}`
|
|
}
|
|
})
|
|
|
|
return sidebar
|
|
}
|