Skip to content

fix(shortcodes): make a minimal nav build and render#2028

Merged
markdumay merged 1 commit into
mainfrom
fix/nav-item-minimal-usage
Jul 15, 2026
Merged

fix(shortcodes): make a minimal nav build and render#2028
markdumay merged 1 commit into
mainfrom
fix/nav-item-minimal-usage

Conversation

@markdumay

Copy link
Copy Markdown
Collaborator

The most natural way to write a nav — one {{< nav >}} with no arguments and a single {{< nav-item >}} — failed two ways, both pre-existing (unrelated to any recent id work; git blame traces them to the v2.7.0 nav commit).

Bug 1 — hard build crash

nav-item.html did isset .Parent.Params "fade". When the parent nav is called with no named arguments, its .Parent.Params is a positional slice, and isset cannot index a slice with a string key:

isset unable to use key of type string as index

So {{< nav >}}...{{< /nav >}} (no args) crashed the whole site build. Guarded with .Parent.IsNamedParams — a named fade can only exist when the parent used named params — which is already an idiom in this file.

Bug 2 — single-item nav doesn't render

A single nav-item stored its collected inner output as template.HTML, while the multi-item path stored a string (via print $current $output). The nav-items partial argument is typed string, so the single-item value was rejected by argument validation and the nav silently failed to render. The single-item branch now coerces with print, matching the multi-item branch exactly.

Why they were masked

Every nav in the theme's own content happens to pass a named argument (dodging bug 1) and two or more items (dodging bug 2), so neither surfaced in normal use — only the minimal, most-obvious usage tripped them.

Verification

Root-caused each with a reproduction, applied the minimal targeted fix for each, and confirmed the minimal nav now builds and renders with its tab button aria-controls correctly paired to its pane, its pane active and showing content, zero console errors. Existing multi-item navs are unaffected. A minimal no-args single-item nav is added to the id-demo fixture, rendered directly, so the build itself guards against a regression — if either bug returns, the build errors.

🤖 Generated with Claude Code

The most natural nav usage - one nav with no arguments and a single item -
failed two ways, both pre-existing:

- `isset .Parent.Params "fade"` hard-crashed the build when the parent nav had
  no named arguments, because .Parent.Params is then a positional slice and
  isset cannot index a slice with a string key. Guard it with
  .Parent.IsNamedParams: a named `fade` can only exist when the parent used
  named params.
- A single nav-item stored its collected `inner` output as template.HTML, while
  the multi-item path stored a string via `print`. The nav-items partial
  argument is typed string, so the single-item value was rejected and the nav
  did not render. Coerce the single-item branch with `print`, matching the
  multi-item branch.

Adds a minimal no-args single-item nav to the id-demo fixture, rendered directly,
so the build itself guards against a regression.
@netlify

netlify Bot commented Jul 15, 2026

Copy link
Copy Markdown

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit d69741f
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6a5775548bc762000830b5ce
😎 Deploy Preview https://deploy-preview-2028--gethinode-demo.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@markdumay markdumay merged commit 07a3367 into main Jul 15, 2026
16 checks passed
@markdumay markdumay deleted the fix/nav-item-minimal-usage branch July 15, 2026 12:11
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.2.4 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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