Merge pull request #427 from northword/master

#426  侧边栏文章标题默认取front matter的title
This commit is contained in:
Evan Xu 2020-12-15 16:42:17 +08:00 committed by GitHub
commit c4d7b889ed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 1 deletions

View File

@ -133,7 +133,12 @@ function mapTocToSidebar (root, collapsable, prefix) {
const contentStr = fs.readFileSync(file, 'utf8') // 读取md文件内容返回字符串
const { data } = matter(contentStr) // 解析出front matter数据
const permalink = data.permalink || ''
sidebar[order] = [prefix + filename, title, permalink]; // [<路径>, <文件标题>, <永久链接>]
const title2 = data.title || title
if (title2) {
sidebar[order] = [prefix + filename, title2, permalink]; // [<路径>, <front matter.title>, <永久链接>]
} else {
sidebar[order] = [prefix + filename, title, permalink]; // [<路径>, <文件标题>, <永久链接>]
}
// 目录页和永久链接,用于给面包屑提供数据
const pageComponent = data.pageComponent