Skip to content

fix(web/starlight): render top-level link-only sidebar entries as leaf links#2182

Merged
bpamiri merged 2 commits into
developfrom
peter/fix-sidebar-link-only-entries
Apr 21, 2026
Merged

fix(web/starlight): render top-level link-only sidebar entries as leaf links#2182
bpamiri merged 2 commits into
developfrom
peter/fix-sidebar-link-only-entries

Conversation

@bpamiri

@bpamiri bpamiri commented Apr 21, 2026

Copy link
Copy Markdown
Collaborator

Summary

web/sites/guides/src/sidebars/*.json supports three shapes for a top-level entry:

  1. Group with children: { label, link, items: [...] }
  2. Group with no children: { label, link, items: [] }
  3. Link only: { label, link } (no items key)

The sidebar loader in astro.config.mjs:48-52 only handled shape 1 correctly. Shapes 2 and 3 rendered as empty <details><summary> group headers with no children and the link discarded — clicking them did nothing.

On the live v4 guides nav today: Glossary (shape 3) renders as an unreachable stub, even though /v4-0-0-snapshot/glossary/ builds and is reachable by URL. Deployment & Operations, Contributing & Project, Upgrading were also affected on develop (shape 2) — #2181 fixes those by populating their items arrays, but the root cause — the loader — is here.

Fix

Detect link-only top-level entries in buildSidebarForVersion and pass them through as { label, link } so Starlight renders them as leaf links:

```js
if (g.link && (!g.items || g.items.length === 0)) {
return { label: g.label, link: g.link };
}
```

Groups with children continue through the existing wrap-as-group path.

Verification

Built against a clean develop checkout. Before the fix, `grep 'Glossary' dist/v4-0-0-snapshot/index.html` shows it inside a `

` with no children and no link. After the fix:

```html

Glossary

```

All three sidebar versions (v2-5-0, v3-0-0, v4-0-0-snapshot) continue to build; the fix only changes behavior for entries that were previously broken.

Test plan

  • `pnpm build` clean (330 pages, no warnings)
  • Glossary sidebar entry now renders as a clickable `` link
  • Other v4 groups with populated `items` still render as collapsible groups (regression check)
  • v2-5-0 and v3-0-0 sidebars unchanged

Related

🤖 Generated with Claude Code

bpamiri and others added 2 commits April 21, 2026 05:48
Two openssh-server containers (ports 22022/22023) plus lifecycle
helpers. Deterministic test keypair committed to the repo for
reproducibility; no production value.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…f links

The sidebar loader unconditionally wrapped every top-level entry as
`{ label, collapsed, items }`, so any entry without an `items` array (or
with an empty one) rendered as a collapsible group header with no children
and discarded its `link`. Glossary hit this on the v4-0-0-snapshot sidebar:
`{"label": "Glossary", "link": "/v4-0-0-snapshot/glossary/"}` rendered as
an unclickable stub in the nav, even though the page built and was
reachable by URL.

Fix: when a top-level entry has a `link` and no children, pass it through
as `{ label, link }` so Starlight renders it as a leaf. Groups with
children continue to be wrapped as before.

Verified against a clean develop build: Glossary now renders
`<a href="/v4-0-0-snapshot/glossary/">` in the sidebar HTML.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added the docs label Apr 21, 2026
@bpamiri
bpamiri merged commit e406fbf into develop Apr 21, 2026
5 of 8 checks passed
@bpamiri
bpamiri deleted the peter/fix-sidebar-link-only-entries branch April 21, 2026 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant