From ebd38339b8d76c45dca818c434744d2f55b2e1ec Mon Sep 17 00:00:00 2001 From: huyikai Date: Wed, 20 Dec 2023 09:40:22 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20locales=20config=20bug=20?= =?UTF-8?q?fix?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/.vitepress/config.ts | 15 ++------------- packages/@huyikai/vitepress-helper/src/init.ts | 2 +- packages/@huyikai/vitepress-helper/src/pages.ts | 10 ++++++---- 3 files changed, 9 insertions(+), 18 deletions(-) diff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.ts index fc56d25..1e2a2cb 100644 --- a/docs/.vitepress/config.ts +++ b/docs/.vitepress/config.ts @@ -2,17 +2,7 @@ import vitepressHelper from '@huyikai/vitepress-helper'; export default async () => { const instance: any = await vitepressHelper({ directory: 'docs', - collapsible: true, - locales: { - root: { - label: '简体中文', - lang: 'zh' - }, - en: { - label: 'English', - lang: 'en' - } - } + collapsible: true }); return { base: '/vitepress-helper/', @@ -61,7 +51,6 @@ export default async () => { prev: 'Pervious', next: 'Next' } - }, - locales: instance.locales + } }; }; diff --git a/packages/@huyikai/vitepress-helper/src/init.ts b/packages/@huyikai/vitepress-helper/src/init.ts index f8656b8..39a076e 100644 --- a/packages/@huyikai/vitepress-helper/src/init.ts +++ b/packages/@huyikai/vitepress-helper/src/init.ts @@ -12,6 +12,6 @@ export default async ( nav: nav(commonParams), sidebar: sidebar(commonParams), pages, - locales: params.locales + locales: params?.locales }; }; diff --git a/packages/@huyikai/vitepress-helper/src/pages.ts b/packages/@huyikai/vitepress-helper/src/pages.ts index eae9918..aad96f0 100644 --- a/packages/@huyikai/vitepress-helper/src/pages.ts +++ b/packages/@huyikai/vitepress-helper/src/pages.ts @@ -26,10 +26,12 @@ export default async (params: InitParams) => { const getNonRootKeys = (obj: any) => { return Object.keys(obj).filter((key) => key !== 'root'); }; - - const localesArray = getNonRootKeys(params.locales).map( - (item) => `${directory}/${item}` - ); + let localesArray: any = []; + if (params?.locales) { + localesArray = getNonRootKeys(params.locales).map( + (item) => `${directory}/${item}` + ); + } // 使用globby查找所有的md文件 const paths = await globby([`${directory}/**/**.md`], {