mirror of
https://github.com/facebook/docusaurus.git
synced 2025-06-15 17:22:35 +02:00
refactor(v2): better docs metadata (#1815)
This commit is contained in:
parent
a04bd440b4
commit
e7ba8af6d9
10 changed files with 185 additions and 149 deletions
|
@ -21,26 +21,12 @@ export default function createOrder(allSidebars: Sidebar = {}): Order {
|
|||
const sidebar = allSidebars[sidebarId];
|
||||
|
||||
const ids: string[] = [];
|
||||
const categoryOrder: (string | undefined)[] = [];
|
||||
const subCategoryOrder: (string | undefined)[] = [];
|
||||
const indexItems = ({
|
||||
items,
|
||||
categoryLabel,
|
||||
subCategoryLabel,
|
||||
}: {
|
||||
items: SidebarItem[];
|
||||
categoryLabel?: string;
|
||||
subCategoryLabel?: string;
|
||||
}) => {
|
||||
const indexItems = ({items}: {items: SidebarItem[]}) => {
|
||||
items.forEach(item => {
|
||||
switch (item.type) {
|
||||
case 'category':
|
||||
indexItems({
|
||||
items: (item as SidebarItemCategory).items,
|
||||
categoryLabel:
|
||||
categoryLabel || (item as SidebarItemCategory).label,
|
||||
subCategoryLabel:
|
||||
categoryLabel && (item as SidebarItemCategory).label,
|
||||
});
|
||||
break;
|
||||
case 'ref':
|
||||
|
@ -49,8 +35,6 @@ export default function createOrder(allSidebars: Sidebar = {}): Order {
|
|||
break;
|
||||
case 'doc':
|
||||
ids.push((item as SidebarItemDoc).id);
|
||||
categoryOrder.push(categoryLabel);
|
||||
subCategoryOrder.push(subCategoryLabel);
|
||||
break;
|
||||
default:
|
||||
throw new Error(
|
||||
|
@ -80,8 +64,6 @@ export default function createOrder(allSidebars: Sidebar = {}): Order {
|
|||
previous,
|
||||
next,
|
||||
sidebar: sidebarId,
|
||||
category: categoryOrder[i],
|
||||
subCategory: subCategoryOrder[i],
|
||||
};
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue