Skip to content

Fix: Remove Empty Anchor Link in Jump-To Menu on Reference Pages #889

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions src/layouts/ReferenceLayout.astro
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,20 @@ 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) {
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;
});

const pageJumpToState: JumpToState = {
links: pageJumpToLinks,
Expand Down