mirror of
https://gitea.com/gitea/docs.git
synced 2026-07-22 02:37:42 +00:00
Sort usage directory by type first (#8)
1. Change name of "usage/actions", "usage/packages" to "usage/Actions" and "usage/Packages". 2. Sort usage directory by type first, so type "category" goes before "docs" Reference from [customize-the-sidebar-items-generator](https://docusaurus.io/docs/sidebar/autogenerated#customize-the-sidebar-items-generator) and [document](https://docusaurus.io/docs/cli#docusaurus-write-translations-sitedir)  Reviewed-on: https://gitea.com/gitea/gitea-docusaurus/pulls/8 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: HesterG <hestergong@gmail.com> Co-committed-by: HesterG <hestergong@gmail.com>
This commit is contained in:
@@ -4,6 +4,15 @@
|
|||||||
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
const lightCodeTheme = require('prism-react-renderer/themes/github');
|
||||||
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
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} */
|
/** @type {import('@docusaurus/types').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
title: 'Gitea Documentation',
|
title: 'Gitea Documentation',
|
||||||
@@ -39,6 +48,16 @@ const config = {
|
|||||||
label: '1.19.3'
|
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,
|
blog: false,
|
||||||
theme: {
|
theme: {
|
||||||
|
|||||||
10
i18n/en/docusaurus-plugin-content-docs/current.json
Normal file
10
i18n/en/docusaurus-plugin-content-docs/current.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user