fix(plugin-notes-data): 侧边栏自动生成 #57

This commit is contained in:
pengzhanbo 2024-03-15 00:39:19 +08:00
parent 16f35c4b36
commit 2ba25c94c7

View File

@ -37,7 +37,7 @@ function resolvedNotesData(app: App, options: NotesDataOptions, result: NotesDat
const { include, exclude, notes, dir: _dir, link } = options
if (!notes || notes.length === 0)
return
const dir = normalizePath(_dir)
const dir = normalizePath(_dir).replace(/^\//, '')
const filter = createFilter(ensureArray(include), ensureArray(exclude), {
resolve: false,
})
@ -152,7 +152,7 @@ function initSidebarByAuto(
let items = result
// eslint-disable-next-line no-cond-assign
while ((dir = paths[index])) {
const text = dir.replace(/\.md$/, '')
const text = dir.replace(/\.md$/, '').replace(/^\d+\./, '')
let current = items.find(item => item.text === text)
if (!current) {
current = { text, link: undefined, items: [] }