Skip to content

Commit

Permalink
fix(docs): the _category_.json description attribute should display o…
Browse files Browse the repository at this point in the history
…n generated index pages (#10324)

Co-authored-by: sebastien <[email protected]>
  • Loading branch information
bharateshwq and slorber authored Aug 9, 2024
1 parent 95ab9f8 commit 44ddada
Show file tree
Hide file tree
Showing 9 changed files with 11 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ exports[`DefaultSidebarItemsGenerator uses explicit link over the index/readme.{
{
"collapsed": undefined,
"collapsible": undefined,
"description": "Category description",
"items": [
{
"id": "parent/doc2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,7 @@ describe('DefaultSidebarItemsGenerator', () => {
categoriesMetadata: {
Category: {
label: 'Category label',
description: 'Category description',
link: {
type: 'doc',
id: 'doc3', // Using a "local doc id" ("doc1" instead of "parent/doc1") on purpose
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,7 @@ describe('validateCategoryMetadataFile', () => {
const content: CategoryMetadataFile = {
className: 'className',
label: 'Category Label',
description: 'Category Description',
link: {
type: 'generated-index',
slug: 'slug',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,9 @@ Available doc IDs:
...(customProps !== undefined && {customProps}),
...(className !== undefined && {className}),
items,
...(categoryMetadata?.description && {
description: categoryMetadata?.description,
}),
...(link && {link}),
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ function postProcessSidebarItem(
.map((subItem) => postProcessSidebarItem(subItem, params))
.filter((v): v is SidebarItem => Boolean(v)),
};

// If the current category doesn't have subitems, we render a normal link
// instead.
if (category.items.length === 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export type PropSidebarBreadcrumbsItem =
export type CategoryMetadataFile = {
label?: string;
position?: number;
description?: string;
collapsed?: boolean;
collapsible?: boolean;
className?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ export function validateSidebars(sidebars: {

const categoryMetadataFileSchema = Joi.object<CategoryMetadataFile>({
label: Joi.string(),
description: Joi.string(),
position: Joi.number(),
collapsed: Joi.boolean(),
collapsible: Joi.boolean(),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"label": "Category Links",
"description": "Category Links - Custom Description",
"link": {
"type": "generated-index",
"slug": "/category-links-generated-index-slug"
Expand Down
1 change: 1 addition & 0 deletions website/_dogfooding/docs-tests-sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ const sidebars = {
{
type: 'category',
label: 'Sidebar item description tests',
description: 'Some custom category description',
link: {
type: 'generated-index',
},
Expand Down

0 comments on commit 44ddada

Please sign in to comment.