Skip to content

Commit

Permalink
feat: nav添加自定义排序
Browse files Browse the repository at this point in the history
  • Loading branch information
yeyunwen committed Feb 3, 2024
1 parent f3d3234 commit 618758e
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion .vitepress/config/nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,27 @@ const generateNavItemWithLink = (
};
};

export const nav = generateNav();
const customSort = [
"JavaScript",
"TypeScript",
"NodeJs",
"Npm",
"Bug",
"Interview",
"服务器",
"规范化",
"构建工具",
"其他",
];

const generateNavWithCustomSort = (
nav: DefaultTheme.NavItem[]
): DefaultTheme.NavItem[] => {
const sortNav: DefaultTheme.NavItem[] = [];
customSort.forEach((item) => {
sortNav.push(nav.find((i) => i.text === item) as DefaultTheme.NavItem);
});
return sortNav;
};

export const nav = generateNavWithCustomSort(generateNav());

0 comments on commit 618758e

Please sign in to comment.