fix(docs): the _category_.json description attribute should display on generated index pages (#10324)

Co-authored-by: sebastien <lorber.sebastien@gmail.com>
This commit is contained in:
Bharatesh 2024-08-09 15:02:21 +05:30 committed by GitHub
parent 95ab9f8ee4
commit 44ddada37a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 11 additions and 0 deletions

View file

@ -217,6 +217,7 @@ exports[`DefaultSidebarItemsGenerator uses explicit link over the index/readme.{
{ {
"collapsed": undefined, "collapsed": undefined,
"collapsible": undefined, "collapsible": undefined,
"description": "Category description",
"items": [ "items": [
{ {
"id": "parent/doc2", "id": "parent/doc2",

View file

@ -331,6 +331,7 @@ describe('DefaultSidebarItemsGenerator', () => {
categoriesMetadata: { categoriesMetadata: {
Category: { Category: {
label: 'Category label', label: 'Category label',
description: 'Category description',
link: { link: {
type: 'doc', type: 'doc',
id: 'doc3', // Using a "local doc id" ("doc1" instead of "parent/doc1") on purpose id: 'doc3', // Using a "local doc id" ("doc1" instead of "parent/doc1") on purpose

View file

@ -282,6 +282,7 @@ describe('validateCategoryMetadataFile', () => {
const content: CategoryMetadataFile = { const content: CategoryMetadataFile = {
className: 'className', className: 'className',
label: 'Category Label', label: 'Category Label',
description: 'Category Description',
link: { link: {
type: 'generated-index', type: 'generated-index',
slug: 'slug', slug: 'slug',

View file

@ -249,6 +249,9 @@ Available doc IDs:
...(customProps !== undefined && {customProps}), ...(customProps !== undefined && {customProps}),
...(className !== undefined && {className}), ...(className !== undefined && {className}),
items, items,
...(categoryMetadata?.description && {
description: categoryMetadata?.description,
}),
...(link && {link}), ...(link && {link}),
}; };
} }

View file

@ -64,6 +64,7 @@ function postProcessSidebarItem(
.map((subItem) => postProcessSidebarItem(subItem, params)) .map((subItem) => postProcessSidebarItem(subItem, params))
.filter((v): v is SidebarItem => Boolean(v)), .filter((v): v is SidebarItem => Boolean(v)),
}; };
// If the current category doesn't have subitems, we render a normal link // If the current category doesn't have subitems, we render a normal link
// instead. // instead.
if (category.items.length === 0) { if (category.items.length === 0) {

View file

@ -217,6 +217,7 @@ export type PropSidebarBreadcrumbsItem =
export type CategoryMetadataFile = { export type CategoryMetadataFile = {
label?: string; label?: string;
position?: number; position?: number;
description?: string;
collapsed?: boolean; collapsed?: boolean;
collapsible?: boolean; collapsible?: boolean;
className?: string; className?: string;

View file

@ -167,6 +167,7 @@ export function validateSidebars(sidebars: {
const categoryMetadataFileSchema = Joi.object<CategoryMetadataFile>({ const categoryMetadataFileSchema = Joi.object<CategoryMetadataFile>({
label: Joi.string(), label: Joi.string(),
description: Joi.string(),
position: Joi.number(), position: Joi.number(),
collapsed: Joi.boolean(), collapsed: Joi.boolean(),
collapsible: Joi.boolean(), collapsible: Joi.boolean(),

View file

@ -1,5 +1,6 @@
{ {
"label": "Category Links", "label": "Category Links",
"description": "Category Links - Custom Description",
"link": { "link": {
"type": "generated-index", "type": "generated-index",
"slug": "/category-links-generated-index-slug" "slug": "/category-links-generated-index-slug"

View file

@ -41,6 +41,7 @@ const sidebars = {
{ {
type: 'category', type: 'category',
label: 'Sidebar item description tests', label: 'Sidebar item description tests',
description: 'Some custom category description',
link: { link: {
type: 'generated-index', type: 'generated-index',
}, },