Skip to content

Autogenerated category with doc link: use doc frontmatter for category metadata #6254

@wenerme

Description

@wenerme

Have you read the Contributing Guidelines on issues?

Description

when construct a category, if exiting README.md like found, use the doc's title and sidebar label for category

const link: SidebarItemCategoryLink | undefined = categoryLinkedDocId
? {
type: 'doc',
id: categoryLinkedDocId, // We "remap" a potentially "local id" to a "qualified id"
}
: // TODO typing issue
(categoryMetadata?.link as SidebarItemCategoryLink | undefined);
// If a doc is linked, remove it from the category subItems
const items = allItems.filter(
(item) => !(item.type === 'doc' && item.id === categoryLinkedDocId),
);
return {
type: 'category',
label: categoryMetadata?.label ?? filename,
collapsible:
categoryMetadata?.collapsible ?? options.sidebarCollapsible,
collapsed: categoryMetadata?.collapsed ?? options.sidebarCollapsed,
position: categoryMetadata?.position ?? numberPrefix,
...(className !== undefined && {className}),
items,
...(link && {link}),

Has this been requested on Canny?

No response

Motivation

migrate old self gen behavior to newer auto gen, but the auto gen require defined category metadata, there are toooo many, just use the README.md or index.md as category's metadata if not found

API design

No response

Have you tried building it?

No response

Self-service

  • I'd be willing to contribute this feature to Docusaurus myself.

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureThis is not a bug or issue with Docusausus, per se. It is a feature request for the future.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions