mirror of
https://github.com/facebook/docusaurus.git
synced 2025-05-15 10:07:33 +02:00
fix(docs): forward doc frontMatter.sidebar_custom_props to linking sidebar category (#7638)
This commit is contained in:
parent
20e8e90762
commit
6df379ca6f
2 changed files with 20 additions and 1 deletions
|
@ -73,10 +73,28 @@ Available document ids are:
|
|||
}
|
||||
}
|
||||
|
||||
function getCategoryLinkCustomProps(
|
||||
link: SidebarItemCategoryLink | undefined,
|
||||
) {
|
||||
switch (link?.type) {
|
||||
case 'doc':
|
||||
return getDocById(link.id).frontMatter.sidebar_custom_props;
|
||||
default:
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
function convertCategory(item: SidebarItemCategory): PropSidebarItemCategory {
|
||||
const {link, ...rest} = item;
|
||||
const href = getCategoryLinkHref(link);
|
||||
return {...rest, items: item.items.map(normalizeItem), ...(href && {href})};
|
||||
const customProps = item.customProps ?? getCategoryLinkCustomProps(link);
|
||||
|
||||
return {
|
||||
...rest,
|
||||
items: item.items.map(normalizeItem),
|
||||
...(href && {href}),
|
||||
...(customProps && {customProps}),
|
||||
};
|
||||
}
|
||||
|
||||
function normalizeItem(item: SidebarItem): PropSidebarItem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue