Skip to content

feat(nav-item): add raw-body to pass an already-rendered body through - #2127

Merged
markdumay merged 1 commit into
mainfrom
feat/nav-item-raw-passthrough
Aug 7, 2026
Merged

feat(nav-item): add raw-body to pass an already-rendered body through#2127
markdumay merged 1 commit into
mainfrom
feat/nav-item-raw-passthrough

Conversation

@markdumay

@markdumay markdumay commented Aug 7, 2026

Copy link
Copy Markdown
Collaborator

Problem

assets/nav-item.html resolves a pane body with $args.body | $args.page.RenderString. That is correct for prose or image bodies, but it destroys a body that is already HTML.

A nav-item whose body is a single nested shortcode reaches RenderString indistinguishable from raw HTML typed directly into markdown. On a site running goldmark with renderer.unsafe = false — which is Hinode's own default, and what exampleSite uses — CommonMark then comments the block out and renders the indented remainder as an escaped code block.

The partial already exposes a raw field that bypasses RenderString entirely (assets/nav-item.html:75,87), but nothing wires it from the shortcode call and no caller in the module sets it, so the field is unreachable from markdown.

Change

Adds an opt-in raw-body boolean to the nav-item shortcode. When set, the already-resolved body is passed straight through as the partial's raw.

It is a separate argument rather than exposing raw itself, because the two carry different things: raw takes the resolved HTML, which cannot sensibly be supplied from a shortcode attribute, while raw-body is the flag that says "my body is already HTML". Overloading one name across the shortcode/partial boundary would put two types behind it.

Declared type: bool, default: false, group: shortcode, so InitArgs resolves it without the | default clobber that would break an explicit false.

Backward compatibility

Defaults to false, so every existing call site is unaffected: the empty string it then passes leaves or $args.raw (...) on the original RenderString path. Both the tab-pane and accordion call sites are wired.

Verification

Built exampleSite (which runs renderer.unsafe = false) with three panes:

Pane Output
Plain prose Just <strong>markdown</strong> prose — existing path unchanged
Nested shortcode, no raw-body <!-- raw HTML omitted --> plus an escaped <pre><code> block — the bug
Nested shortcode, raw-body=true <div class="d-flex alert alert-info" role="alert"> — renders correctly

npm test passes (lint + template tests).

Note for anyone reproducing locally: a stale _vendor will fail test:templates with unrelated section-title schema errors — pnpm mod:vendor fixes it (mine was pinned at mod-utils v6.8.3 against a v6.9.0 requirement).

Downstream

Found on a downstream site that renders a tabbed component whose panes each hold a single nested shortcode. It currently carries a full-file fork of this shortcode as an interim workaround; the fork is deleted once this ships.

assets/nav-item.html resolves a pane body with `body | page.RenderString`,
which is correct for prose but destroys a body that is already HTML. A
nav-item whose body is a nested shortcode reaches RenderString
indistinguishable from raw HTML typed into markdown, so a site running
goldmark with renderer.unsafe = false escapes or drops it — the pane shows a
stray comment and an escaped code block instead of the component.

The partial already accepts a `raw` field that bypasses RenderString, but
nothing wired it from the shortcode, leaving the field unreachable from
markdown. raw-body opts into it.

It is a separate argument rather than exposing `raw` itself because the two
carry different things: `raw` takes resolved HTML, which cannot be supplied
from a shortcode attribute, while raw-body is the flag saying the body is
already HTML.

Defaults to false, so every existing call site is unaffected: the empty
string it then passes leaves `or .raw (...)` on the original path.
@netlify

netlify Bot commented Aug 7, 2026

Copy link
Copy Markdown

Deploy Preview for gethinode-demo ready!

Name Link
🔨 Latest commit 4510a44
🔍 Latest deploy log https://app.netlify.com/projects/gethinode-demo/deploys/6a75b9847bda220008702f12
😎 Deploy Preview https://deploy-preview-2127--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 a8b5f6d into main Aug 7, 2026
17 checks passed
@markdumay
markdumay deleted the feat/nav-item-raw-passthrough branch August 7, 2026 11:52
@markdumay

Copy link
Copy Markdown
Collaborator Author

🎉 This PR is included in version 3.21.0 🎉

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