Skip to content

Fix: markdown routes & copy page button - #511

Merged
jbmoelker merged 1 commit into
mainfrom
fix/pages-as-markdown
Oct 11, 2026
Merged

jbmoelker merged 1 commit into
mainfrom
fix/pages-as-markdown

Conversation

@jbmoelker

Copy link
Copy Markdown
Member

Changes

Why: since the move to Workers (#463), every .md route returned a 522 and the "Copy page" button showed "Failed". This PR fixes both.

Details:

  • Markdown routes read the page from the ASSETS binding or render it with rewrite(), because a Worker can't fetch its own URL. In astro dev they fetch from the dev server.
  • "Copy page" fetches from the current origin, so it works locally and on preview, and copies within the click, as Safari requires.
  • Layout: copy icon, icon aligned with the text, same spacing as the breadcrumbs, no external link icons in the dropdown.
  • CMS: "Open as markdown" is now "View as Markdown" in all environments.

Associated issue

Follow-up of #463 (migrate to Workers).

How to test

  1. npm run dev and open /api/content/en.md: returns markdown with frontmatter. /api/content/en/does-not-exist.md returns 404.
  2. On any page, click "Copy page": the label changes to "Copied" and the clipboard holds the page as markdown. Try in Safari as well.
  3. Open the dropdown: "View as Markdown" and the LLM links have no external link icon.
  4. After deploying, repeat step 2 on the Worker URL (both prerendered and on-demand pages).

Checklist

  • I have performed a self-review of my own code
  • I have made sure that my PR is easy to review (not too big, includes comments)
  • I have made updated relevant documentation files (in project README, docs/, etc)
  • I have added a decision log entry if the change affects the architecture or changes a significant technology
  • I have notified a reviewer Just fixes I double checked myself, also in another project. If something breaks, we can do a follow-up.

- Markdown routes (`/api/content/{path}.md`) no longer fetch the page over
  HTTP, which fails on Workers (522). Prerendered pages are read from the
  ASSETS binding, on-demand pages are rendered with `rewrite()`, and
  `astro dev` fetches from the dev server.
- "Copy page" fetches the markdown from the current origin and starts the
  clipboard write within the click, so it works locally, on previews and
  in Safari.
- "Copy page" gets a copy icon, icon/text alignment and spacing matching
  the breadcrumbs; the dropdown items no longer show an external link icon.
@cloudflare-workers-and-pages

Copy link
Copy Markdown

🚀 Deploying Preview to Cloudflare 🚀

Preview URL: https://fix-pages-as-markdown-head-start.voorhoede.workers.dev (commit 152fb4b)

This URL reflects your latest Preview deployment

Preview Deployments by commit

Status Deployment URL Commit Updated (UTC) See this deployment's details
  • Build: Success ✅
  • Deployment: Success ✅

View logs ↗
https://00142330-head-start.voorhoede.workers.dev 152fb4b 2026-10-11T19:58:04.924Z Visit the dashboard ↗

@jbmoelker jbmoelker self-assigned this Oct 11, 2026
@jbmoelker
jbmoelker merged commit 5f598a0 into main Oct 11, 2026
5 checks passed
@jbmoelker
jbmoelker deleted the fix/pages-as-markdown branch October 11, 2026 20:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant