From 5c9ae4138006f0a2079d709c1099fb2f608beb63 Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Mon, 18 Mar 2024 00:11:39 +0800 Subject: [PATCH] perf(theme): notes list filter --- theme/src/node/resolveNotesList.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/theme/src/node/resolveNotesList.ts b/theme/src/node/resolveNotesList.ts index d72fc585..e1be3d15 100644 --- a/theme/src/node/resolveNotesList.ts +++ b/theme/src/node/resolveNotesList.ts @@ -1,7 +1,7 @@ import type { NotesDataOptions, NotesSidebar } from '@vuepress-plume/plugin-notes-data' import type { PlumeThemeLocaleOptions } from '../shared/index.js' import { resolveLocaleOptions } from './resolveLocaleOptions.js' -import { pathJoin } from './utils.js' +import { normalizePath, pathJoin } from './utils.js' export function resolveNotesList(options: PlumeThemeLocaleOptions) { const locales = options.locales || {} @@ -10,8 +10,9 @@ export function resolveNotesList(options: PlumeThemeLocaleOptions) { for (const locale of Object.keys(locales)) { const notes = resolveLocaleOptions(options, 'notes', locale, false) if (notes) { - if (!notes.dir.includes(locale)) - notes.dir = pathJoin(locale, notes.dir) + const dir = normalizePath(`/${notes.dir}`) + if (!dir.startsWith(locale)) + notes.dir = pathJoin(locale, notes.dir).replace(/^\//, '') notesList.push(notes) }