Sort usage directory by type first #8

Merged
lunny merged 2 commits from HesterG/gitea-docusaurus:usage-sort-type into main 2023-05-22 08:31:35 +00:00
2 changed files with 29 additions and 0 deletions

View File

@ -4,6 +4,15 @@
const lightCodeTheme = require('prism-react-renderer/themes/github');
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
// order usage directory by type first
function sortItemsByCategory(items) {
// type with "category" (directory) first
const sortedItems = items.sort(function(a, b) {
return a.type.localeCompare(b.type);
})
return sortedItems;
}
/** @type {import('@docusaurus/types').Config} */
const config = {
title: 'Gitea Documentation',
@ -39,6 +48,16 @@ const config = {
label: '1.19.3'
}
},
async sidebarItemsGenerator({defaultSidebarItemsGenerator, ...args}) {
const {item} = args;
// Use the provided data to generate a custom sidebar slice
const sidebarItems = await defaultSidebarItemsGenerator(args);
if (item.dirName !== 'usage') {
return sidebarItems;
} else {
return sortItemsByCategory(sidebarItems);
}
},
},
blog: false,
theme: {

View File

@ -0,0 +1,10 @@
{
"sidebar.defaultSidebar.category.actions": {
"message": "Actions",
"description": "The label for category actions in sidebar defaultSidebar"
},
"sidebar.defaultSidebar.category.packages": {
"message": "Packages",
"description": "The label for category packages in sidebar defaultSidebar"
}
}