mirror of
https://github.com/ZiuChen/ZiuChen.github.io.git
synced 2025-08-18 23:49:33 +08:00
fix: 生成侧边栏时排除资源文件夹
This commit is contained in:
parent
f6fa4975dc
commit
3849a5b3a4
@ -4,14 +4,19 @@ import path from 'path'
|
|||||||
export default function generateSideBar() {
|
export default function generateSideBar() {
|
||||||
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
const articles = fs.readdirSync(path.resolve(__dirname, '../../article'))
|
||||||
|
|
||||||
const sidebar = articles.map((article) => {
|
// 排除掉资源文件夹
|
||||||
// 移除后缀 `.md`
|
const folders = ['assets']
|
||||||
const title = article.replace(/\.md$/, '')
|
|
||||||
return {
|
const sidebar = articles
|
||||||
text: title,
|
.filter((article) => !folders.includes(article))
|
||||||
link: `/article/${title}`
|
.map((article) => {
|
||||||
}
|
// 移除后缀 `.md`
|
||||||
})
|
const title = article.replace(/\.md$/, '')
|
||||||
|
return {
|
||||||
|
text: title,
|
||||||
|
link: `/article/${title}`
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
return sidebar
|
return sidebar
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user