fix(docs): Fix empty sidebar item category className lost when post-processed to a doc (#11281)

This commit is contained in:
Sébastien Lorber 2025-06-19 19:04:28 +02:00 committed by GitHub
parent 068d4c63a9
commit 1cbc0118b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
10 changed files with 45 additions and 20 deletions

View file

@ -76,6 +76,10 @@ exports[`postProcess transforms category without subitems 1`] = `
{
"sidebar": [
{
"className": "category-className",
"customProps": {
"custom": true,
},
"id": "doc ID",
"label": "Category 2",
"type": "doc",

View file

@ -31,6 +31,8 @@ describe('postProcess', () => {
type: 'doc',
id: 'doc ID',
},
className: 'category-className',
customProps: {custom: true},
items: [],
},
],

View file

@ -77,10 +77,13 @@ function postProcessSidebarItem(
) {
return null;
}
const {label, className, customProps} = category;
return {
type: 'doc',
label: category.label,
id: category.link.id,
label,
...(className && {className}),
...(customProps && {customProps}),
};
}
// A non-collapsible category can't be collapsed!