Update sidebar.ts

This commit is contained in:
huan_kong 2023-06-29 14:59:48 +08:00 committed by GitHub
parent 606834d753
commit 7c3b1adae7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -13,9 +13,13 @@ import type { PlumeThemePageData } from '../../shared/index.js'
import { isActive } from '../utils/index.js'
import { useThemeLocaleData } from './themeData.js'
export function normalizePath(path: string) {
return path.replace(/\/\\+/g, '/').replace(/\\+/g, '/')
}
export function getSidebarList(path: string, notesData: NotesData) {
const link = Object.keys(notesData).find((link) =>
path.startsWith(withBase(link))
path.startsWith(normalizePath(withBase(link)))
)
return link ? notesData[link] : []
}