Skip to content

fix: Include Render partial headings in page TOC - #32267

Merged
mvvmm merged 4 commits into
productionfrom
fix/partial-render-toc
Jul 27, 2026
Merged

fix: Include Render partial headings in page TOC#32267
mvvmm merged 4 commits into
productionfrom
fix/partial-render-toc

Conversation

@mvvmm

@mvvmm mvvmm commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

Consumes the pkg.pr.new Nimbus build from cloudflare/nimbus#36, which adds partialHeadings support to getDocsPageProps.

Adds the cloudflare-docs-specific resolvePartialId resolver to src/pages/[...slug].astro, matching Render.astro's product ? ${product}/${file} : file convention. This lets Nimbus collect markdown headings from the same partials that render in-page via <Render>.

Adds src/util/rendered-toc.ts, a utility that detects when a page (or its transitive <Render> partials) uses AnchorHeading — a component that emits headings at runtime via set:html, making them invisible to compile-time heading extraction. When runtime headings are detected, the utility renders the page through an AstroContainer to scrape the actual <h*> elements from the rendered HTML. It also transitively resolves partial-to-partial <Render> references to determine which partials are "dynamic" (contain AnchorHeading directly or through a dependency chain).

Fixes literal markdown headings inside rendered partials missing from the page TOC. For example, /bots/plans/pro/ now includes "Bot settings versus custom rules" (from partials/bots/bot-settings-vs-custom-rules.mdx) in its on-this-page TOC.

Does not fix AnchorHeading-generated headings; those are runtime component output and need a separate cloudflare-docs-specific follow-up if desired.

Documentation checklist

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

This pull request requires reviews from CODEOWNERS as it changes files that match the following patterns:

Pattern Owners
package.json @cloudflare/content-engineering
* @cloudflare/product-owners
*.astro @cloudflare/content-engineering, @kodster28
*.ts @cloudflare/content-engineering, @kodster28

@github-actions

github-actions Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

@mvvmm
mvvmm marked this pull request as ready for review July 23, 2026 05:19
@mvvmm
mvvmm requested review from a team and kodster28 as code owners July 23, 2026 05:19
@cloudflare-docs-bot

cloudflare-docs-bot Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Review

⚠️ 1 warning found in commit b02c6b8.

👉 Fix in your agent 👈
Fix the following review findings in PR #32267 (https://github.com/cloudflare/cloudflare-docs/pull/32267).

Before making changes, review each finding and present a brief summary table:
- For each finding, state whether you agree, disagree, or need clarification
- If you disagree (e.g. the fix requires disproportionate effort for minimal benefit,
  or the finding is factually incorrect), explain why
- If you need clarification before deciding, ask those questions
- Then share your plan for which issues to tackle and in what order

After triaging, follow this order:
1. Post a comment on this PR for any findings you are skipping, with the finding ID and your reasoning.
2. Then commit the fixes for the legitimate findings.

The comment must come before the commit — the bot reads PR comments when a new
push triggers a review, so skip comments posted after the push will be missed.

---

## Code Review

### Warnings (1)

#### CR-63820172e021 · Regex cannot match multiline JSX attributes
- **File:** `src/util/rendered-toc.ts` line 29
- **Issue:** The file/product attribute regexes on lines 29–30 use `.`, which does not match newline characters. `<Render>` usage in the repo is commonly multiline, so `file`/`product` attributes that follow a newline will not be captured and referenced dynamic partials will be missed.
- **Fix:** Add the `s` flag to the attribute regexes (e.g. `/\bfile=["']([^"']+)["']/s`) so `.` matches newlines, or use `[^]*?`/single capture when parsing the whole tag.

Code Review

This code review is in beta and may not always be helpful — use your judgment.

Warnings (1)
File Issue
src/util/rendered-toc.ts line 29 Regex cannot match multiline JSX attributes — The file/product attribute regexes on lines 29–30 use ., which does not match newline characters. <Render> usage in the repo is commonly multiline, so file/product attributes that follow a newline will not be captured and referenced dynamic partials will be missed. Fix: Add the s flag to the attribute regexes (e.g. /\bfile=["']([^"']+)["']/s) so . matches newlines, or use [^]\*?/single capture when parsing the whole tag.

Conventions

No convention issues found.

Style Guide Review

No style-guide issues found.

Commands

Only codeowners can run commands. Post a comment with the command to trigger it.

Command Description
/review Runs a review now. Incremental if a prior review exists, full if not.
/full-review Re-reviews the entire PR diff from scratch, ignoring incremental history. Useful after a rebase, when you want a fresh review, or if the bot gets out of sync and reports issues that no longer exist.
/ignore-review-limit Permanently lifts the 2-review automatic limit for this PR. Future pushes will trigger reviews as normal.
/disable-auto-review Stops automatic reviews from triggering on future pushes to this PR. Codeowners can still run /review or /full-review manually.
/rebase Rebases the PR branch against production. On conflict, attempts to resolve automatically using AI. Stops with an explanation if confidence is not high enough.

@mvvmm
mvvmm marked this pull request as draft July 23, 2026 05:19
@MohamedH1998
MohamedH1998 marked this pull request as ready for review July 23, 2026 11:56
@mvvmm

mvvmm commented Jul 24, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@cloudflare-docs-bot
cloudflare-docs-bot Bot force-pushed the fix/partial-render-toc branch from 6e56e56 to 42c2e4a Compare July 24, 2026 16:55
@mvvmm

mvvmm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@cloudflare-docs-bot
cloudflare-docs-bot Bot force-pushed the fix/partial-render-toc branch from 42c2e4a to e91c3c0 Compare July 27, 2026 17:45
@mvvmm

mvvmm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Triage: findings skipped

CR-5d3e0f3f11de & CR-343fe494b089 — Race condition in lazy singleton init

Skipping. ??= evaluates the RHS and assigns the result synchronously in the same tick. Both computeDynamicPartials() and loadRenderers().then() return Promises immediately (async functions / Promise-returning APIs). The assignment to the module-level variable happens before any await yields control. A second caller reaching the same line will see the already-assigned Promise, not undefined. There is no interleaving window in single-threaded JS — the nullish coalescing assignment is atomic with respect to the event loop.

CR-c5a92a1bb422 — Direct tarball bypasses internal registry gateway

Skipping. The tarball URL is intentional and documented in the comment above the override. The internal registry gateway does not mirror @cloudflare/nimbus-docs, so a scope-level .npmrc rule (@cloudflare:registry=...) cannot be narrowed to a single package — it would route all @cloudflare/* packages to the public registry, breaking the gateway for every other Cloudflare dependency. The per-package tarball override is the only mechanism pnpm offers to bypass the scope rule for one package while leaving it intact for the rest.

@mvvmm

mvvmm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

Update: override removed

CR-0481180a08c6 and CR-c5a92a1bb422 are now moot — the entire overrides block for @cloudflare/nimbus-docs has been removed. The version in package.json is now the single source of truth, and the package resolves through the normal registry path like every other dependency.

@mvvmm

mvvmm commented Jul 27, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@mvvmm
mvvmm force-pushed the fix/partial-render-toc branch from 39cb4ad to b02c6b8 Compare July 27, 2026 19:24
@mvvmm
mvvmm merged commit 7a8a083 into production Jul 27, 2026
17 checks passed
@mvvmm
mvvmm deleted the fix/partial-render-toc branch July 27, 2026 20:11
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.

4 participants