mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-08-17 23:19:55 +08:00
20 lines
468 B
TypeScript
20 lines
468 B
TypeScript
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
|
|
}
|