From 7d128398383022012d3d69a13a606b4f2567eafd Mon Sep 17 00:00:00 2001 From: pengzhanbo Date: Fri, 30 Jun 2023 01:38:51 +0800 Subject: [PATCH] fix(theme): normalize blog&category path --- packages/theme/src/node/plugins.ts | 4 +++- packages/theme/src/node/setupPages.ts | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/packages/theme/src/node/plugins.ts b/packages/theme/src/node/plugins.ts index faff9e8a..428a6c2d 100644 --- a/packages/theme/src/node/plugins.ts +++ b/packages/theme/src/node/plugins.ts @@ -39,7 +39,9 @@ export const setupPlugins = ( const localeNotesDirs = Object.keys(locales) .map((locale) => { const dir = locales[locale].notes?.dir || '' - return dir ? path.join(locale, dir, '**').replace(/^\//, '') : '' + return dir + ? path.join(locale, dir, '**').replace(/\\+/g, '/').replace(/^\//, '') + : '' }) .filter(Boolean) diff --git a/packages/theme/src/node/setupPages.ts b/packages/theme/src/node/setupPages.ts index 57c5d402..b1c67042 100644 --- a/packages/theme/src/node/setupPages.ts +++ b/packages/theme/src/node/setupPages.ts @@ -43,7 +43,8 @@ export function autoCategory( const notesLinks: string[] = [] for (const [, locale] of locales.entries()) { const notes = options.locales?.[locale]?.notes - if (notes && notes.link) notesLinks.push(path.join(locale, notes.link)) + if (notes && notes.link) + notesLinks.push(path.join(locale, notes.link).replace(/\\+/g, '/')) } if (notesLinks.some((link) => page.path.startsWith(link))) return const RE_LOCALE = new RegExp(