Skip to content

fix: Include Render partial headings in page TOC#32267

Open
mvvmm wants to merge 3 commits into
productionfrom
fix/partial-render-toc
Open

fix: Include Render partial headings in page TOC#32267
mvvmm wants to merge 3 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}` : fileconvention. This lets Nimbus collect markdown headings from the same partials that render in-page via`.

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

⚠️ 3 warnings, 💡 3 suggestions found in commit 6e56e56.

👉 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 (3)

#### CR-87f9094495f5 · Stale global cache in dev
- **File:** `src/util/rendered-toc.ts` line 59
- **Issue:** dynamicPartials is computed once and cached for the module lifetime; edits to partials that add or remove AnchorHeading will not be reflected until the dev server restarts.
- **Fix:** Add an invalidation hook tied to the content layer, or recompute the dynamic partials set when partial collection versions change during dev.

#### CR-9b55932ee252 · Swallowed runtime-heading scrape failure
- **File:** `src/pages/[...slug].astro` line 89
- **Issue:** If `scrapeRenderedHeadings` throws, the `catch` logs to stderr but falls back to the compile-time `headings` array, so the runtime headings the PR is adding will be silently omitted for that page.
- **Fix:** Surface extraction failures explicitly (e.g., rethrow or fail the build) instead of silently falling back, or at least emit a clear build-level warning so missing headings are not masked.

#### CR-5e9ed82e2260 · Redundant dependency override
- **File:** `package.json` line 164
- **Issue:** The `@cloudflare/nimbus-docs` devDependency is pinned to `0.7.1` and a `pnpm.overrides` entry also forces the same package to the `0.7.1` tarball URL. If the dependency version is bumped later without updating the override, pnpm will silently continue installing the old tarball.
- **Fix:** Remove the `pnpm.overrides` entry if the direct dependency pin is sufficient, or add a comment explaining why the override is required for transitive resolution.

### Suggestions (3)

#### CR-5f74a8ee6f18 · Redundant minimumReleaseAgeExclude entry
- **File:** `pnpm-workspace.yaml` line 27
- **Issue:** The newly added `overrides` entry resolves `@cloudflare/nimbus-docs` from a pinned tarball URL, bypassing registry age checks entirely. This makes the earlier `minimumReleaseAgeExclude: @cloudflare/nimbus-docs` entry (whose comment says it exempts freshly-cut registry versions from the 24h wait) redundant and its justification inconsistent with the override.
- **Fix:** Remove `@cloudflare/nimbus-docs` from `minimumReleaseAgeExclude` since the tarball override already sidesteps registry age checks, or document why both settings are needed if there is another reason.

#### CR-6c5665c1f111 · Regex-based Render detection is fragile
- **File:** `src/util/rendered-toc.ts` line 21
- **Issue:** body.matchAll(/<Render\b[^>]*>/g) matches literal <Render> tags anywhere in the raw MDX source, including code blocks and documentation examples.
- **Fix:** Use MDX AST parsing to locate actual Render component usages instead of regex-matching raw source.

#### CR-57e8bf6bface · Whole-page double render
- **File:** `src/pages/[...slug].astro` line 88
- **Issue:** When runtime headings are detected, the entire `Content` component is rendered again in an `AstroContainer` only to collect headings, adding build overhead for every affected page.
- **Fix:** Consider caching the container render or extracting headings directly from partial HTML to avoid rendering the full page twice.

Code Review

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

Warnings (3)
File Issue
src/util/rendered-toc.ts line 59 Stale global cache in dev — dynamicPartials is computed once and cached for the module lifetime; edits to partials that add or remove AnchorHeading will not be reflected until the dev server restarts. Fix: Add an invalidation hook tied to the content layer, or recompute the dynamic partials set when partial collection versions change during dev.
src/pages/[...slug].astro line 89 Swallowed runtime-heading scrape failure — If scrapeRenderedHeadings throws, the catch logs to stderr but falls back to the compile-time headings array, so the runtime headings the PR is adding will be silently omitted for that page. Fix: Surface extraction failures explicitly (e.g., rethrow or fail the build) instead of silently falling back, or at least emit a clear build-level warning so missing headings are not masked.
package.json line 164 Redundant dependency override — The @cloudflare/nimbus-docs devDependency is pinned to 0.7.1 and a pnpm.overrides entry also forces the same package to the 0.7.1 tarball URL. If the dependency version is bumped later without updating the override, pnpm will silently continue installing the old tarball. Fix: Remove the pnpm.overrides entry if the direct dependency pin is sufficient, or add a comment explaining why the override is required for transitive resolution.
Suggestions (3)
File Issue
pnpm-workspace.yaml line 27 Redundant minimumReleaseAgeExclude entry — The newly added overrides entry resolves @cloudflare/nimbus-docs from a pinned tarball URL, bypassing registry age checks entirely. This makes the earlier minimumReleaseAgeExclude: @cloudflare/nimbus-docs entry (whose comment says it exempts freshly-cut registry versions from the 24h wait) redundant and its justification inconsistent with the override. Fix: Remove @cloudflare/nimbus-docs from minimumReleaseAgeExclude since the tarball override already sidesteps registry age checks, or document why both settings are needed if there is another reason.
src/util/rendered-toc.ts line 21 Regex-based Render detection is fragile — body.matchAll(/<Render\b[^>]*>/g) matches literal tags anywhere in the raw MDX source, including code blocks and documentation examples. Fix: Use MDX AST parsing to locate actual Render component usages instead of regex-matching raw source.
src/pages/[...slug].astro line 88 Whole-page double render — When runtime headings are detected, the entire Content component is rendered again in an AstroContainer only to collect headings, adding build overhead for every affected page. Fix: Consider caching the container render or extracting headings directly from partial HTML to avoid rendering the full page twice.

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
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.

3 participants