uncategorized blocks in sidebar

This commit is contained in:
Loren Norman 2025-07-25 14:48:49 -04:00
parent 49cf69b4f4
commit 65fd5959bc
2 changed files with 18 additions and 5 deletions

View file

@ -1,5 +1,5 @@
import { writeFileSync } from 'fs'
import { forEach, isString, without } from 'lodash-es'
import { isString, without } from 'lodash-es'
export default class BlockIndexExporter {

View file

@ -25,17 +25,30 @@ export default class SidebarExporter {
collapsed: true,
items: []
}))
},
uncategorizedCategory = {
text: "Uncategorized",
collapsed: true,
items: []
}
blockSidebar.items.push(uncategorizedCategory)
forEach(this.definitionSet.blocks, blockDefinition => {
const sidebarEntry = {
text: blockDefinition.name,
link: blockDefinition.documentationPath()
const
sidebarEntry = {
text: blockDefinition.name,
link: blockDefinition.documentationPath()
},
blockCategories = blockDefinition.getCategories()
// put into Uncategorized if no category
if(!blockCategories.length) {
uncategorizedCategory.items.push(sidebarEntry)
}
// add links to each sidebar category we're a part of
forEach(blockDefinition.getCategories(), category => {
forEach(blockCategories, category => {
// if category contains this block, add to its sidebar
const sidebarCategory = find(blockSidebar.items, { text: category.name })