Hide items from sidebar
This commit is contained in:
parent
ae182ddb15
commit
ae1b704151
|
@ -1,5 +1,6 @@
|
||||||
---
|
---
|
||||||
slug: /
|
slug: /
|
||||||
|
id: intro
|
||||||
sidebar_position: 1
|
sidebar_position: 1
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ const lightCodeTheme = require('prism-react-renderer/themes/github');
|
||||||
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
const darkCodeTheme = require('prism-react-renderer/themes/dracula');
|
||||||
const math = require('remark-math');
|
const math = require('remark-math');
|
||||||
const katex = require('rehype-katex');
|
const katex = require('rehype-katex');
|
||||||
|
const { filterItems } = require('./sidebar-utils');
|
||||||
|
|
||||||
/** @type {import('@docusaurus/types').Config} */
|
/** @type {import('@docusaurus/types').Config} */
|
||||||
const config = {
|
const config = {
|
||||||
|
@ -38,7 +39,16 @@ const config = {
|
||||||
routeBasePath: '/', // serve the docs at the site's route
|
routeBasePath: '/', // serve the docs at the site's route
|
||||||
|
|
||||||
sidebarPath: require.resolve('./sidebars.js'),
|
sidebarPath: require.resolve('./sidebars.js'),
|
||||||
|
async sidebarItemsGenerator({ defaultSidebarItemsGenerator, ...args }) {
|
||||||
|
const sidebarItems = await defaultSidebarItemsGenerator(args);
|
||||||
|
|
||||||
|
const itemsToFilterOut = [
|
||||||
|
'data-model/entities/entity-identifiers',
|
||||||
|
'data-model/entities/other'
|
||||||
|
];
|
||||||
|
|
||||||
|
return filterItems(sidebarItems, itemsToFilterOut);
|
||||||
|
},
|
||||||
// Please change this to your repo.
|
// Please change this to your repo.
|
||||||
// Remove this to remove the "edit this page" links.
|
// Remove this to remove the "edit this page" links.
|
||||||
// editUrl:
|
// editUrl:
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
// filter out specific items from the sidebar
|
||||||
|
function filterItems(items, itemsToFilter) {
|
||||||
|
|
||||||
|
// filter out items of categories
|
||||||
|
let result = items.map((item) => {
|
||||||
|
if (item.type === 'category') {
|
||||||
|
return {...item, items: filterItems(item.items, itemsToFilter)};
|
||||||
|
}
|
||||||
|
return item;
|
||||||
|
});
|
||||||
|
|
||||||
|
// filter out items in current level
|
||||||
|
return result.filter( item => !itemsToFilter.includes(item.id) );
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
filterItems
|
||||||
|
};
|
Loading…
Reference in New Issue