-
Notifications
You must be signed in to change notification settings - Fork 184
Description
What package is the bug related to?
typedoc-vitepress-theme
Describe the issue
Hello! First, thank you for your work <3
I just found a bug related to the auto-generated sidebar and navigation items without a group (@group none).
From the TypeDoc documentation i can read: "A group called none (case-insensitive) is reserved and treated specially by the default theme to be displayed without a group heading before list of groups.", but it's not rendered in the vitepress sidebar.
I tried to log the content of output.navigation by manually editing the typedoc-plugin-markdown/dist/renderer/render.js#render function and the item without group correctly appears:
[
{
title: 'my-module',
children: [
// ✔ Navigation items without group (@group none)
[
{
title: 'MyClassWithoutGroup',
kind: 128,
path: 'path/to/my/class/without/group.md',
isDeprecated: false,
children: []
}
],
// Other collapsible items
{ title: 'Classes', children: [ ... ] },
{ title: 'Functions', children: [ ... ] },
...
]
}
...
]❗ Note that the item is in an array
After investigation, I've found a lead. It appears the typedoc-vitepress-theme/src/sidebars/sidebar.vitepress.ts#getNavigationItem function doesn't consider array of items:
typedoc-plugin-markdown/packages/typedoc-vitepress-theme/src/sidebars/sidebar.vitepress.ts
Lines 15 to 20 in 29e0bb2
| function getNavigationItem( | |
| navigationItem: NavigationItem, | |
| basePath: string, | |
| options: any, | |
| ) { | |
| const hasChildren = navigationItem?.children?.length; |
So, actually my auto-generated sidebar in typedoc-sidebar.json contains an empty object:
{
"text": "my-module",
"link": "/link/to/my-module/",
"collapsed": true,
"items": [
// ⛔ Here the unexpected empty object
{},
{
"text": "Classes",
"collapsed": true,
"items": [ "..." ]
},
{
"text": "Functions",
"collapsed": true,
"items": [ "..." ]
}
]
}PS: sorry my bad english 🥶
TypeDoc configuration
Versions
Configuration
typedoc.config.mjs:
export default {
plugin: [
'typedoc-plugin-markdown',
'typedoc-vitepress-theme'
],
readme: 'none',
navigation: {
includeGroups: true,
includeFolders: false
},
/**
* typedoc-plugin-markdown
*/
useCodeBlocks: true,
parametersFormat: 'table',
sidebar: {
pretty: true
}
}Expected behavior
The auto-generated sidebar should be:
{
"text": "my-module",
"link": "/path/to/my-module/",
"collapsed": true,
"items": [
// ✔ Here the expected destructured items without group
{
"text": "MyClassWithoutGroup",
"link": "path/to/my/class/without/group.md"
},
{
"text": "Classes",
"collapsed": true,
"items": [ "..." ]
},
{
"text": "Functions",
"collapsed": true,
"items": [ "..." ]
}
]
}