Skip to content

fix(preview-links): honor custom frontmatter id when deriving doc URLs#4937

Merged
lennessyy merged 2 commits into
mainfrom
fix/preview-links-honor-doc-id
Jul 21, 2026
Merged

fix(preview-links): honor custom frontmatter id when deriving doc URLs#4937
lennessyy merged 2 commits into
mainfrom
fix/preview-links-honor-doc-id

Conversation

@lennessyy

@lennessyy lennessyy commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Summary

The docs PR preview-link generator (bin/generate-docs-preview-list.js) built a page's URL from its filename when the page had no slug frontmatter, ignoring a custom id. Docusaurus derives a slug-less doc's URL from the directory path plus its id (which defaults to the filename but can be overridden in frontmatter). So any page that sets a custom id without a slug got an incorrect preview link.

Reported on #4906: docs/production-deployment/self-hosted-guide/temporal-nexus.mdx sets id: nexus, so it publishes at .../self-hosted-guide/nexus, but the preview comment linked to .../self-hosted-guide/temporal-nexus.

This isn't unique to that PR — it affects every page with a custom id and no slug (e.g. the SDK set-up.mdx pages with id: set-up-your-local-<lang>, and references/client-envrionment-configuration.mdx whose id corrects a filename typo).

Changes

  • extractFrontMatter now also reads id.
  • Slug derivation substitutes a custom id for the last path segment, falling back to the existing filename/index behavior when no id is set. Explicit slug frontmatter still takes precedence (unchanged).
  • Moved the BASE_SHA guard into main() so the module's pure helpers are importable by tests without the process exiting.
  • Added tests/test-docs-preview-list.mjs covering: custom id override, no-id filename fallback, index handling (with and without a custom id), whitespace id, and slug-wins-over-id precedence.

Verification

  • New suite passes; full node tests/run-all.mjs passes (87 tests).
  • Ran the generator against the real temporal-nexus.mdx: it now emits slug production-deployment/self-hosted-guide/nexus (was .../temporal-nexus).

How the URL rule was validated

Confirmed Docusaurus's id→URL behavior against existing repo pages, not just the reported one: internal links to develop/go/set-up.mdx (id: set-up-your-local-go) all use the id-based path, and links to the misspelled-filename client-envrionment-configuration.mdx (id: client-environment-configuration) all use the id spelling.

┆Attachments: EDU-6776 fix(preview-links): honor custom frontmatter id when deriving doc URLs

The docs PR preview-link generator built a page's URL purely from its
filename when no `slug` frontmatter was present, ignoring a custom `id`.
Docusaurus derives a slug-less doc's URL from the directory path plus its
`id` (which defaults to the filename but can be overridden), so any page
setting a custom `id` without a `slug` got a wrong preview link.

Example: docs/production-deployment/self-hosted-guide/temporal-nexus.mdx
sets `id: nexus`, so it publishes at .../self-hosted-guide/nexus, but the
generator linked to .../self-hosted-guide/temporal-nexus.

extractFrontMatter now also reads `id`, and slug derivation substitutes it
for the filename segment (falling back to today's filename/index behavior
when no id is set). slug frontmatter still takes precedence.

Also moves the BASE_SHA guard into main() so the module's pure helpers can
be imported by tests without the process exiting. Adds a test suite
covering the id/slug/filename cases.
@lennessyy
lennessyy requested a review from a team as a code owner July 21, 2026 20:51
@vercel

vercel Bot commented Jul 21, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
temporal-documentation Ready Ready Preview, Comment Jul 21, 2026 9:05pm

Request Review

@github-actions

Copy link
Copy Markdown
Contributor

📖 Docs PR preview links

This PR does not change any pages in /docs. If you make updates, links to the modified pages will appear here.

@lennessyy
lennessyy merged commit 18755f5 into main Jul 21, 2026
11 checks passed
@lennessyy
lennessyy deleted the fix/preview-links-honor-doc-id branch July 21, 2026 21:08
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.

2 participants