mirror of
https://github.com/Gar-b-age/CookLikeHOC.git
synced 2026-08-31 15:47:13 +00:00
fix(nav): section.nav_link -> README.md
This commit is contained in:
@@ -53,6 +53,9 @@ export function generateNavAndSidebar(rootDir: string) {
|
|||||||
link: `/${encodeURI(dir)}/${encodeURI(f)}`,
|
link: `/${encodeURI(dir)}/${encodeURI(f)}`,
|
||||||
}))
|
}))
|
||||||
|
|
||||||
|
// Find README.md、readme.md、index.md
|
||||||
|
const readme = ['README.md', 'readme.md', 'index.md'].find((n) => fs.existsSync(path.join(abs, n)))
|
||||||
|
|
||||||
if (items.length > 0) {
|
if (items.length > 0) {
|
||||||
sidebar[`/${dir}/`] = [
|
sidebar[`/${dir}/`] = [
|
||||||
{
|
{
|
||||||
@@ -60,11 +63,12 @@ export function generateNavAndSidebar(rootDir: string) {
|
|||||||
items,
|
items,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
if (readme) {
|
||||||
// First doc becomes nav link for section
|
nav.push({ text: dir, link: `/${encodeURI(dir)}/${encodeURI(readme)}` })
|
||||||
nav.push({ text: dir, link: items[0].link! })
|
} else {
|
||||||
|
nav.push({ text: dir, link: items[0].link! })
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// Empty section: still show in nav to directory index if exists
|
|
||||||
nav.push({ text: dir, link: `/${encodeURI(dir)}/` })
|
nav.push({ text: dir, link: `/${encodeURI(dir)}/` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user