feat(llm-exports): MDX template overrides and declarative page sections#16417
feat(llm-exports): MDX template overrides and declarative page sections#16417
Conversation
…gation Load public/doctree.json to replace raw slug names with proper titles in generated .md files. Adds a sectionOverrides registry for clean per-page customization of appended navigation sections. Changes: - Root index.md: platforms by title, frameworks grouped by platform, doc sections by title - platforms.md: structured Platforms + Frameworks sections - Platform pages (e.g. platforms/javascript.md): "Frameworks" with proper titles, sorted "Topics" - Guide pages (e.g. platforms/javascript/guides/nextjs.md): "Other Frameworks" + "Topics" - All other section pages: titles and sidebar_order from doctree - Graceful fallback to slug-based output if doctree unavailable Closes #16413 Co-Authored-By: Claude <noreply@anthropic.com>
- Refactor root index.md generation to use contentOverrides registry (same pattern as sectionOverrides but for full page replacement) - Track content override results for proper R2 upload handling - Add specs/llm-friendly-docs.md documenting the content negotiation system, override architecture, and page customization patterns Co-Authored-By: Claude <noreply@anthropic.com>
…ports Replace imperative JS builder functions with two-layer customization: - MDX templates in md-overrides/ for full-page content (like root index.md) with custom components (PlatformList, FrameworkGroups, DocSectionList) - Declarative pageOverrides table for appended navigation sections MDX templates are rendered to HTML via React SSR, then flow through the existing HTML→MD worker pipeline automatically getting link rewriting, caching, and R2 sync. This replaces ~10 builder functions and two separate override registries with a unified architecture. Co-Authored-By: Claude <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Use non-recursive readdir for md-overrides/ so that dev/ subdirectory files are not discovered during production builds. Co-Authored-By: Claude <noreply@anthropic.com>
…ms.md - index.md now shows full sitemap: platforms, frameworks, and every top-level section with its children expanded (via SectionTree component) - platforms.md gets MDX override with curated platforms/frameworks listing, doc sections, and quick links - Add SectionTree component that renders doctree sections with children Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
The H1 already comes from the frontmatter title, so the H2 was redundant. Co-Authored-By: Claude <noreply@anthropic.com>
13af8b8 to
61fa729
Compare
Replace "/platforms" link (which points to itself) with a link back to the root documentation index. Co-Authored-By: Claude <noreply@anthropic.com>
| await mkdir(targetDir, {recursive: true}); | ||
| const targetPath = path.join(targetDir, dirent.name.slice(0, -5) + '.md'); | ||
| const relativePath = path.relative(OUTPUT_DIR, targetPath); | ||
| // Use MDX override HTML if available, otherwise use Next.js build HTML | ||
| const mdxOverride = mdxOverrides.get(relativePath); | ||
| workerTasks[workerIdx].push({ | ||
| sourcePath, | ||
| sourcePath: mdxOverride ? mdxOverride.htmlPath : sourcePath, | ||
| targetPath, | ||
| relativePath, | ||
| r2Hash: existingFilesOnR2 ? existingFilesOnR2.get(relativePath) : null, |
There was a problem hiding this comment.
Bug: MDX overrides are silently ignored if their corresponding Next.js-generated HTML file is missing, with no warning or error logged to indicate the override was not applied.
Severity: MEDIUM
Suggested Fix
After the file discovery loop finishes, iterate through the mdxOverrides map. For each override that was rendered, check if it was consumed and processed by a worker. If any overrides were not used, log a warning to the console indicating which MDX files were ignored. This will alert developers to configuration issues or typos.
Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.
Location: scripts/generate-md-exports.mjs#L600-L609
Potential issue: The script processes MDX overrides by first looking for corresponding
`.html` files generated by Next.js in the `.next/server/app/` directory. A worker task
to process an MDX override is only created if a matching HTML file is found. If a
developer adds an MDX override file (e.g., `new-page.mdx`) but Next.js fails to generate
the corresponding HTML file (e.g., due to a typo or a configuration issue), the override
will be silently ignored. The script logs that the override was rendered to an
intermediate HTML file, but provides no warning or error that it was never actually
used, which could lead to confusion and outdated content being deployed.
Did we get this right? 👍 / 👎 to inform future reviews.
Prevents silent failures when an override file has a typo or its corresponding page doesn't exist in the build output. Co-Authored-By: Claude <noreply@anthropic.com>
sergical
left a comment
There was a problem hiding this comment.
lgtm apart from the yarn.lock not being part of this, but idk if its already a dependency there and there are no changes because you're just explicitly adding the dependency that was already there from mdx-js
Improve the LLM markdown export pipeline (
generate-md-exports.mjs) withstructured page customization. Previously, custom pages like
index.mdwere built entirely from JS string concatenation (~30+ line builder
functions), and two separate override registries with incompatible
interfaces handled content vs. navigation overrides.
This introduces a two-layer architecture:
MDX templates (
md-overrides/) for pages needing fully custom content.Templates use React components (
PlatformList,FrameworkGroups,DocSectionList) that close overdocTreeand render to HTML. Therendered HTML flows through the existing worker pipeline — link rewriting,
caching, and R2 sync all work automatically with no special handling.
Declarative
pageOverridestable for appended navigation sections.Each entry declares
{heading, items}pairs instead of imperative builderfunctions. Shared utilities (
nodeLinks,childLinks,siblingGuideLinks) handle the common patterns. Abuildescape hatchremains for complex cases like the grouped platforms page.
This replaces ~10 builder functions and merges the two override registries
into a single unified system. The spec at
specs/llm-friendly-docs.mdisupdated to document the new architecture.
Closes #16413