2023-02-05 15:07:58 +08:00

18 lines
397 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.map((article) => {
// 移除后缀 `.md`
const title = article.replace(/\.md$/, '')
return {
text: title,
link: `/article/${title}`
}
})
return sidebar
}