Skip to content

Commit

Permalink
* docs: change doc sidebar config.
Browse files Browse the repository at this point in the history
  • Loading branch information
catouse committed Jul 16, 2024
1 parent 599cea3 commit a7ca073
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions docs/_/.vitepress/theme-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,13 +184,26 @@ function createSidebar() {
const files = glob.sync(`*/*/**/*.md`, {onlyFiles: true, cwd: libDocsPath});
updateSections(files, sidebars, libDocsPath, lib);
});

const orders = {
'介绍': 1,
'快速上手': 2,
'教程': 3,
'兼容性': 4,
};

Object.keys(sidebars).forEach(key => {
sidebars[key] = sidebars[key].filter(section => {
if (section.hidden || !section.items?.length) {
return false;
}
if (section.items) {
section.items = section.items.sort((a, b) => {
const order1 = orders[a.text!];
const order2 = orders[b.text!];
if (typeof order1 === 'number' && typeof order2 === 'number') {
return order1 - order2;
}
let result = (a.lib ? 1 : 0) - (b.lib ? 1 : 0);
if (result !== 0) {
return result;
Expand Down

0 comments on commit a7ca073

Please sign in to comment.