Charles 4 weeks ago committed by GitHub
commit 0c1a1723f6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -27,11 +27,18 @@ export function getSidebar(
const dir = Object.keys(_sidebar) const dir = Object.keys(_sidebar)
.sort((a, b) => { .sort((a, b) => {
// longer dir link has higher priority
return b.split('/').length - a.split('/').length return b.split('/').length - a.split('/').length
}) })
.find((dir) => { .find((dir) => {
const dirWithStartingSlash = ensureStartingSlash(dir)
// make sure the multi sidebar key starts with slash too // make sure the multi sidebar key starts with slash too
return path.startsWith(ensureStartingSlash(dir)) if (path.startsWith(dirWithStartingSlash)) {
// "/" match everything and it has lowest priority
if (dirWithStartingSlash === '/') return true
const remains = path.replace(dirWithStartingSlash, '')
if (remains.startsWith('/') || remains === '') return true
}
}) })
const sidebar = dir ? _sidebar[dir] : [] const sidebar = dir ? _sidebar[dir] : []

Loading…
Cancel
Save