mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-08-17 23:19:55 +08:00
fix: 生成侧边栏时排除资源文件夹
This commit is contained in:
parent
f6fa4975dc
commit
3849a5b3a4
@ -4,14 +4,19 @@ 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}`
|
||||
}
|
||||
})
|
||||
// 排除掉资源文件夹
|
||||
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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user