Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(content-docs): add support for sidebar item category/link descriptions in generated index page #8236

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type SidebarItemLink = SidebarItemBase & {
href: string;
label: string;
autoAddBaseUrl?: boolean;
description?: string;
};

export type SidebarItemAutogenerated = SidebarItemBase & {
Expand All @@ -69,6 +70,7 @@ export type SidebarItemCategoryLinkGeneratedIndexConfig = {
image?: string;
keywords?: string | readonly string[];
};

export type SidebarItemCategoryLinkGeneratedIndex = {
type: 'generated-index';
slug: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const sidebarItemLinkSchema = sidebarItemBaseSchema.append<SidebarItemLink>({
label: Joi.string()
.required()
.messages({'any.unknown': '"label" must be a string'}),
description: Joi.string().optional().messages({
'any.unknown': '"description" must be a string',
}),
});

const sidebarItemCategoryLinkSchema = Joi.object<SidebarItemCategoryLink>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ function CardLink({item}: {item: PropSidebarItemLink}): JSX.Element {
href={item.href}
icon={icon}
title={item.label}
description={doc?.description}
description={
isInternalUrl(item.href) ? doc?.description : item.description
slorber marked this conversation as resolved.
Show resolved Hide resolved
}
/>
);
}
Expand Down
6 changes: 6 additions & 0 deletions website/_dogfooding/docs-tests-sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ const sidebars = {
label: 'External Link test',
href: 'https://docusaurus.io',
},
{
type: 'link',
label: 'External Link with description',
href: 'https://docusaurus.io',
description: 'Some description',
},
slorber marked this conversation as resolved.
Show resolved Hide resolved
],
},
{
Expand Down