Skip to content

Commit 9802bcf

Browse files
authored
[Docs Site] Fix hideIndex and external_link in sidebar (#20752)
1 parent 8c77f64 commit 9802bcf

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/util/sidebar.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,13 @@ async function handleGroup(group: Group): Promise<SidebarEntry> {
225225
}
226226

227227
const idx = group.entries.indexOf(index);
228+
229+
if (idx === -1) {
230+
throw new Error(
231+
`[Sidebar] Originally located ${index.href} in ${group.label} entries but unable to find it post-transform`,
232+
);
233+
}
234+
228235
const removed = group.entries.splice(idx, 1).at(0) as Link;
229236

230237
removed.attrs = {
@@ -270,7 +277,7 @@ async function handleLink(link: Link): Promise<Link> {
270277
link.badge = inferBadgeVariant(link.badge);
271278
}
272279

273-
if (frontmatter.external_link) {
280+
if (frontmatter.external_link && !frontmatter.sidebar.group?.hideIndex) {
274281
return {
275282
...link,
276283
label: link.label.concat(rehypeExternalLinksOptions.content.value),

0 commit comments

Comments
 (0)