From 73d8a8ca430a68db2e3d4b4327da1a1e676d0c9d Mon Sep 17 00:00:00 2001 From: Reshma R Date: Tue, 1 Jul 2025 23:27:47 +0900 Subject: [PATCH 1/3] Fixes #881 --- src/layouts/ReferenceLayout.astro | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/layouts/ReferenceLayout.astro b/src/layouts/ReferenceLayout.astro index b3df8d82c7..2ca9cc45ca 100644 --- a/src/layouts/ReferenceLayout.astro +++ b/src/layouts/ReferenceLayout.astro @@ -140,10 +140,30 @@ const jumpCategoryData = categoryData.length === 1 ? [...categoryData, ...categoryData[0].subcats] : categoryData; -const pageJumpToLinks: JumpToLink[] = jumpCategoryData.map((category) => ({ - label: category.name as string, - url: `#${category.name}`, -})); +const pageJumpToLinks: JumpToLink[] = jumpCategoryData + .map((categoryItem) => ({ + label: categoryItem.name as string, + url: `#${categoryItem.name}`, + })) + .filter((link, index) => { + if (link.label === undefined) { + // When categoryData.length is 1 (e.g., on /reference/p5.sound/), + // jumpCategoryData is [mainCategory, ...mainCategory.subcats]. + // The first subcategory often has an undefined name and represents general entries + // listed directly under the main category heading. + // jumpCategoryData[0] links to the main category (e.g., "p5.sound" -> "#p5.sound"). + // jumpCategoryData[1] would be this link with an undefined label. + // Since its content is covered by the main category link, this link is redundant. + if (categoryData.length === 1 && index === 1) { + return false; // Remove this redundant link + } + // Fallback for any other unexpected undefined labels from this layout. + // This ensures no link generated by this logic is truly empty. + // A more descriptive label should ideally be formed if these cases are known. + link.label = uiTranslations["Details"] || "Details"; + } + return true; + }); const pageJumpToState: JumpToState = { links: pageJumpToLinks, From ea3db86848f5207492dc9f868f3cb609a92dd1ae Mon Sep 17 00:00:00 2001 From: Reshma R <77575603+reshma045@users.noreply.github.com> Date: Sun, 6 Jul 2025 12:11:45 +0900 Subject: [PATCH 2/3] Update ReferenceLayout.astro --- src/layouts/ReferenceLayout.astro | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/layouts/ReferenceLayout.astro b/src/layouts/ReferenceLayout.astro index 2ca9cc45ca..eab6eba024 100644 --- a/src/layouts/ReferenceLayout.astro +++ b/src/layouts/ReferenceLayout.astro @@ -145,22 +145,12 @@ const pageJumpToLinks: JumpToLink[] = jumpCategoryData label: categoryItem.name as string, url: `#${categoryItem.name}`, })) - .filter((link, index) => { + .filter((link, index) => { if (link.label === undefined) { - // When categoryData.length is 1 (e.g., on /reference/p5.sound/), - // jumpCategoryData is [mainCategory, ...mainCategory.subcats]. - // The first subcategory often has an undefined name and represents general entries - // listed directly under the main category heading. - // jumpCategoryData[0] links to the main category (e.g., "p5.sound" -> "#p5.sound"). - // jumpCategoryData[1] would be this link with an undefined label. - // Since its content is covered by the main category link, this link is redundant. - if (categoryData.length === 1 && index === 1) { - return false; // Remove this redundant link - } - // Fallback for any other unexpected undefined labels from this layout. - // This ensures no link generated by this logic is truly empty. - // A more descriptive label should ideally be formed if these cases are known. - link.label = uiTranslations["Details"] || "Details"; + return false; // Completely remove all undefined labels + } + if (categoryData.length === 1 && index === 1) { + return false; // Specifically remove the redundant subcat under main cat } return true; }); From 4cd7ebcac2536918233a15901916f018538f2a46 Mon Sep 17 00:00:00 2001 From: Reshma R Date: Wed, 23 Jul 2025 17:52:59 +0900 Subject: [PATCH 3/3] issue properly fixed --- src/layouts/ReferenceLayout.astro | 18 +++++------------- 1 file changed, 5 insertions(+), 13 deletions(-) diff --git a/src/layouts/ReferenceLayout.astro b/src/layouts/ReferenceLayout.astro index eab6eba024..3a952b922a 100644 --- a/src/layouts/ReferenceLayout.astro +++ b/src/layouts/ReferenceLayout.astro @@ -141,19 +141,11 @@ const jumpCategoryData = categoryData.length === 1 : categoryData; const pageJumpToLinks: JumpToLink[] = jumpCategoryData - .map((categoryItem) => ({ - label: categoryItem.name as string, - url: `#${categoryItem.name}`, - })) - .filter((link, index) => { - if (link.label === undefined) { - return false; // Completely remove all undefined labels - } - if (categoryData.length === 1 && index === 1) { - return false; // Specifically remove the redundant subcat under main cat - } - return true; - }); + .filter((category) => !!category.name) // REMOVE undefined ones + .map((category) => ({ + label: category.name as string, + url: `#${category.name}`, + })); const pageJumpToState: JumpToState = { links: pageJumpToLinks,