fix(shortcodes): make a minimal nav build and render#2028
Merged
Conversation
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.
✅ Deploy Preview for gethinode-demo ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Collaborator
Author
|
🎉 This PR is included in version 3.2.4 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 blametraces them to the v2.7.0 nav commit).Bug 1 — hard build crash
nav-item.htmldidisset .Parent.Params "fade". When the parent nav is called with no named arguments, its.Parent.Paramsis a positional slice, andissetcannot index a slice with a string key:So
{{< nav >}}...{{< /nav >}}(no args) crashed the whole site build. Guarded with.Parent.IsNamedParams— a namedfadecan 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
inneroutput astemplate.HTML, while the multi-item path stored a string (viaprint $current $output). Thenav-itemspartial argument is typedstring, so the single-item value was rejected by argument validation and the nav silently failed to render. The single-item branch now coerces withprint, 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-controlscorrectly 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 theid-demofixture, rendered directly, so the build itself guards against a regression — if either bug returns, the build errors.🤖 Generated with Claude Code