Skip to content

Commit

Permalink
fix: 🐛 locales config bug fix
Browse files Browse the repository at this point in the history
  • Loading branch information
huyikai committed Dec 20, 2023
1 parent 930305f commit ebd3833
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 18 deletions.
15 changes: 2 additions & 13 deletions docs/.vitepress/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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/',
Expand Down Expand Up @@ -61,7 +51,6 @@ export default async () => {
prev: 'Pervious',
next: 'Next'
}
},
locales: instance.locales
}
};
};
2 changes: 1 addition & 1 deletion packages/@huyikai/vitepress-helper/src/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ export default async (
nav: nav(commonParams),
sidebar: sidebar(commonParams),
pages,
locales: params.locales
locales: params?.locales
};
};
10 changes: 6 additions & 4 deletions packages/@huyikai/vitepress-helper/src/pages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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`], {
Expand Down

0 comments on commit ebd3833

Please sign in to comment.