Skip to content

Render markdown during the static build - #649

Open
vipulpandey21 wants to merge 1 commit into
containers:mainfrom
vipulpandey21:fix/markdown-server-render
Open

Render markdown during the static build#649
vipulpandey21 wants to merge 1 commit into
containers:mainfrom
vipulpandey21:fix/markdown-server-render

Conversation

@vipulpandey21

@vipulpandey21 vipulpandey21 commented Aug 6, 2026

Copy link
Copy Markdown

Fixes #648

Markdown wrapped ReactMarkdown in BrowserOnly, which renders nothing during the static build. So any text passed through it was missing from the HTML and only appeared after hydration. 19 call sites, including PageHeader and SectionHeader.

Before

$ curl -s https://podman.io/features | grep -c "Podman makes it easy to find"
0

After (local build)

$ grep -c "Podman makes it easy to find" build/features.html
1

Words of text in the HTML:

page before after
/ 364 495
/features 414 525
/community 442 944
/get-started 718 826

/community went from 16 missing lines to 0.

The tsconfig change. react-markdown v8 is ESM only, and the base config sets moduleResolution: Node16, so a static import gives TS1479. This only affects yarn typecheck, the webpack build is fine either way. Setting module: esnext and moduleResolution: node clears it, and the error count is the same 6 pre-existing ones before and after. Happy to do this another way if you would rather not touch tsconfig.

This also looks like the original reason for the dynamic import. React 17 cannot render Suspense on the server, which is what #18 ran into in 2023.

Checked: yarn build passes, no console errors on the built site, the styles prop still applies, and the bundle is slightly smaller without the lazy chunk (1026 to 1025 chunks).

Notes: the BrowserOnly in HeroHeader needs the browser for OS detection, so I left it. #524 touches the same file and will conflict, happy to rebase if that goes in first.

I used an LLM to help write this description. The work and the testing are mine and I can explain any of it.

The Markdown component wrapped ReactMarkdown in BrowserOnly, so every
string passed through it was missing from the generated HTML and only
appeared after hydration. That covers 19 call sites, including
PageHeader and SectionHeader, which are on every custom page.

Import react-markdown directly and render it normally. tsconfig needs
module and moduleResolution set so tsc accepts a static import of an
ESM only package; the webpack build already handled this.

Fixes: containers#648
Signed-off-by: Vipul Subhash Pandey <vipulpandey7917@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Text rendered through the Markdown component is missing from the built HTML

1 participant