Skip to content

The .mdx copy/view links 404 on all six non-default locales — the rewrite only covers the unprefixed path #207

Description

@hotlong

Found while verifying #180 against a running build. Unrelated to that card and deliberately not fixed there — #180's surface was apps/docs/app/[lang]/layout.tsx, and this lives in next.config.mjs.

(Angle-bracket markup omitted throughout — this repo's sanitizer strips it.)

What happens

Every docs page renders a "Copy Markdown" button and a "View as Markdown" link, both pointing at page.url plus .mdx. On a locale-prefixed page page.url carries the prefix, so the link is /zh-Hans/docs/architecture.mdx.

next.config.mjs rewrites only the unprefixed shape:

async rewrites() {
  return [
    { source: '/docs/:path*.mdx', destination: '/llms.mdx/docs/:path*' },
  ];
}

There is no locale-prefixed variant, so every prefixed .mdx URL falls through to app/[lang]/docs/[[...slug]], where architecture.mdx is not an enumerated slug, and 404s.

Measured

Against next start on a production build of b61f04e:

page markdownUrl it renders that URL answers
/docs/architecture /docs/architecture.mdx 200
/zh-Hans/docs/architecture /zh-Hans/docs/architecture.mdx 404
/ja/docs/architecture /ja/docs/architecture.mdx 404

The markdownUrl values were read out of the served payload, not off the source.

Six of the seven locales are affected, on every one of the 79 docs pages — so roughly 400 rendered links that 404. English is the only locale where the button works.

Why it is worth fixing

  • It is a visible, clickable dead end in the UI, not a machine-facing edge case. A reader on any non-English page who clicks "Copy Markdown" gets a 404 page.
  • The .mdx surface is the AI-facing half of this site (it is what llms.txt and the copy button exist for), so the locales where it silently fails are exactly the ones least likely to be spot-checked by an English-speaking maintainer.

Directions (not adjudicated)

  1. Add a locale-prefixed rewrite alongside the existing one (/:lang/docs/:path*.mdx), and decide what the handler serves for a locale that has no translation — presumably the same English fallback the page itself serves.
  2. Have the page emit the unprefixed .mdx URL regardless of locale, on the grounds that app/llms.mdx/... is default-locale-only by the same reasoning as fix(docs): serve llms-full.txt in the default locale only #183. That makes the link work everywhere but hands a reader on a translated page the English markdown.

These differ in what a translated page's markdown should be, which is a content question, not a routing one.

Filed unassigned for triage.


Generated by Claude Code

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions