Skip to content

Add .md URL stripping redirects for legacy links#140

Closed
LucHeart wants to merge 1 commit intomasterfrom
codex/add-redirect-for-.md-links
Closed

Add .md URL stripping redirects for legacy links#140
LucHeart wants to merge 1 commit intomasterfrom
codex/add-redirect-for-.md-links

Conversation

@LucHeart
Copy link
Copy Markdown
Member

Motivation

  • Preserve compatibility with legacy markdown-style links by redirecting any incoming path that ends with .md to the same path without the extension so old links keep working.

Description

  • Add a dev-time Next.js redirect in next.config.mjs that permanently maps /:path*.md to /:path* so local/dev server behavior matches production.
  • Add production redirect rules in public/_redirects to strip .md on Cloudflare Pages and include a specific /legal/*.md mapping to /home/legal/:splat while keeping existing root/legal rules.

Testing

  • Ran pnpm lint which passed with no warnings or errors.
  • Ran pnpm build which completed successfully and generated the static pages without errors.

Codex Task

@cloudflare-workers-and-pages
Copy link
Copy Markdown

cloudflare-workers-and-pages bot commented Apr 15, 2026

Deploying openshock-wiki with  Cloudflare Pages  Cloudflare Pages

Latest commit: 934a33f
Status: ✅  Deploy successful!
Preview URL: https://629d4cb8.openshock-wiki.pages.dev
Branch Preview URL: https://codex-add-redirect-for--md-l.openshock-wiki.pages.dev

View logs

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 934a33fe2c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread public/_redirects
@@ -1,2 +1,4 @@
/legal/*.md /home/legal/:splat 301
/*.md /:splat 301
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*P1 Badge Exclude llms markdown endpoints from .md redirect

The new catch-all rule /*.md -> /:splat also matches internal markdown endpoints such as /llms.mdx/docs/.../content.md, which are intentionally generated by getPageMarkdownUrl and exported from src/app/llms.mdx/docs/[[...slug]]/route.ts using generateStaticParams. Redirecting those requests to /.../content strips the required .md segment, so production static exports no longer have a matching file at the redirected path, causing markdown-view/copy links to fail with 404s.

Useful? React with 👍 / 👎.

@LucHeart LucHeart closed this Apr 15, 2026
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.

1 participant