Skip to content

📚 Add Markdown content negotiation guide and fix docs tables - #58

Merged
isaaclombardssw merged 7 commits into
mainfrom
codex/markdown-content-negotiation-guide
Nov 11, 2026
Merged

isaaclombardssw merged 7 commits into
mainfrom
codex/markdown-content-negotiation-guide

Conversation

@isaaclombardssw

@isaaclombardssw isaaclombardssw commented Sep 22, 2026 •

Copy link
Copy Markdown
Contributor

Add a guide for serving source MDX at existing page URLs when clients prefer Markdown. The Next.js 15 example matches TinaDocs' shipped middleware; Astro and Vite use the same negotiator selection for quality values, wildcards, and media-type casing.

The guide covers Vary: Accept, CDN cache separation, static-hosting limits, Astro's request-time rendering and source-file requirements, its content layout and draft assumptions, and a negotiation test matrix. Added to Technical Guides navigation.

This also fixes the shared table renderer, so it affects every docs page with a Markdown table. table.tsx looked for rows in a shape TinaMarkdown doesn't pass, so tables rendered empty, including on the live network-requirements page. It now uses TinaMarkdown's tr, th, and td components. Cells skip the rest of the component mapping, so link and code styles sit on the table.

Validation:

  • pnpm tinacms build --local --skip-cloud-checks, Biome, and tsc.
  • Ran the guide's snippets as real apps and tested the Accept table at /docs and nested paths: Next.js 15.5.29 (next start), Astro 7.4.7 (Node adapter), Vite 8.3.6 (dev and preview). Not tested on a CDN.
  • Checked the guide and table pages in a browser. Added tests/e2e/tables.spec.ts; Playwright passes against a local dev server, excluding the search specs.

Related: tinacms/tina-docs#355; tinacms/tina.io#4896.

@isaaclombardssw
isaaclombardssw requested a review from a team as a code owner September 22, 2026 00:37
@vercel

vercel Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Nov 6, 2026 4:40am UTC

Request Review

pnpm add -D @types/negotiator
```

<Callout variant="warning" body="MDX can contain JSX and TinaCMS components. Most AI agents can still read it, but clients that require CommonMark may need a separate MDX-to-Markdown conversion step." />

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

The preview shows the whole guide as raw source, because this string body fails the MDX parse.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Switched to the JSX body form the other docs use.

Create a server endpoint for the source MDX:

```typescript
// src/pages/_markdown/[...slug].ts

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I ran this on Astro 7, every text/markdown request returned a 404 because Astro skips _ folders under src/pages, and after a rename every path served index.mdx.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ Moved the endpoint to src/pages/api/markdown and switched to context.rewrite, because next() kept the docs route params. Tested on Astro 7.4.7.


Also test negotiation at both `/docs` and a nested docs URL:

| `Accept` header | Expected response |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Once the page parses this table renders with no rows, the same as the six tables on https://tina.io/docs/tinacloud/network-requirements, because table.tsx misses them.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ table.tsx now renders what TinaMarkdown passes. This also restores the six tables on network-requirements, and I added an e2e check.

response.appendHeader("Vary", "Accept");
const type = new Negotiator({
headers: { accept: request.headers.accept ?? "*/*" },
}).mediaType(["text/html", "text/markdown"]);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When I ran the Vite example, text/* returned a 404 with no content type, where the table below expects HTML.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

✅ text/* now returns HTML. Vite only runs its HTML fallback when Accept names text/html or */*, so the example appends text/html for HTML requests.

@kulesy

kulesy commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Hey Isaac,

Could you update this branch from main when you push the fixes? It's 9 commits behind and the checks are strict, so it can't merge until then.

isaaclombardssw and others added 3 commits November 6, 2026 15:11
- Use a JSX body on the callout so the page parses
- Move the Astro endpoint out of the underscore folder and use
  context.rewrite so params match the rewritten route
- Normalise Accept in the Vite example so Vite's HTML fallback runs
- Render docs tables from the thead and tbody TinaMarkdown passes, which
  also restores the tables on other docs pages

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- State the guide's content layout, draft, and basePath assumptions
- Keep the original Accept value in the Vite example so CSS still loads
- Style links and code in table cells, restore the header divider
- Add an e2e check for Markdown table rows

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@isaaclombardssw isaaclombardssw changed the title 📚 Add Markdown content negotiation guide 📚 Add Markdown content negotiation guide and fix docs tables Nov 6, 2026
@isaaclombardssw

Copy link
Copy Markdown
Contributor Author

Updated from main and pushed the fixes. Checks are green.

@isaaclombardssw
isaaclombardssw merged commit b08857b into main Nov 11, 2026
7 checks passed
@isaaclombardssw
isaaclombardssw deleted the codex/markdown-content-negotiation-guide branch November 11, 2026 01:13

This branch was successfully deployed

1 active deployment
Preview — 9e8bfef7 Deployed Nov 6, 2026 by vercel[bot]
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