Skip to content

Agent-readable docs: Phase 1 — markdown alternates, alt link, helpful 404, headers#101

Merged
tbantle22 merged 3 commits into
devfrom
neon-docs-lessons
Jun 2, 2026
Merged

Agent-readable docs: Phase 1 — markdown alternates, alt link, helpful 404, headers#101
tbantle22 merged 3 commits into
devfrom
neon-docs-lessons

Conversation

@tbantle22
Copy link
Copy Markdown
Collaborator

Phase 1 of the agent-docs plan in notes/agent-readable-docs.md (added in commit 9504074). Gives every docs page a Markdown URL that agents can fetch, advertises it from the HTML head, and adds the response headers prod actually needs to serve it correctly. No content changes — only the surface around content.

What's in

File(s) Change
site/{dolt,doltlab,doltgres}/src/pages/[...slug].md.ts (new) Static endpoint that re-serves the raw Markdown source at the .md suffix. Uses import.meta.glob with ?raw so the bytes match src/content/ exactly. Same contentRouteSlug as the HTML catch-all, so /docs/foo/bar and /docs/foo/bar.md always refer to the same source.
site/shared/layouts/DocsLayout.astro <link rel="alternate" type="text/markdown" href="<page>.md"> in the head. Skipped on the docs root (/docs.md isn't useful).
site/{dolt,doltlab,doltgres}/src/pages/404.astro Expanded from the one-line "Back to home" to a helpful page — home link, search hint, and a callout pointing at the .md alternate convention.
site/{dolt,doltlab,doltgres}/_headers (new) Cloudflare Pages response headers. Vary: Accept on /docs/* so caches differentiate HTML vs. Markdown for the same URL. Explicit Content-Type: text/markdown; charset=utf-8 + an hour of public caching on /docs/*.md (Cloudflare otherwise defaults .md to text/plain).
site/{dolt,doltlab,doltgres}/package.json cp _headers dist/_headers in each build script, next to the existing cp _redirects.
cypress/e2e/dolt/markdown-alternate.spec.ts (new) Verifies the .md endpoint returns 200 with the raw source (frontmatter intact), that the HTML head advertises the alternate, that nested paths work, and that unknown .md paths return 404.
cypress/e2e/dolt/navigation.spec.ts Update the "renders the custom 404 page" assertion to the new wording; add coverage that the .md-alternate hint is on the page.

Verification

  • All three sites build: dolt 139 .md alternates, doltlab 75, doltgres 62 (matching the canonical page counts).
  • Cypress: markdown-alternate (4/4), navigation (5/5), dead-links (15/15) all pass.
  • Sample: curl http://localhost:4321/docs/introduction/installation.md returns the raw source with frontmatter; <link rel="alternate" type="text/markdown" href="/docs/introduction/installation.md"> is in the HTML <head>; no such link on the root index.html.

What's still ahead

Phase 2 (llms.txt generated from nav.ts + frontmatter description:) and Phase 3 (breadcrumbs, related docs, content backfill) per the plan in notes/agent-readable-docs.md. Phase 1 alone unlocks ~80% of the agent UX without touching any content.

tbantle22 and others added 3 commits June 1, 2026 16:25
Source: https://neon.com/blog/agents-grew-up-so-did-our-docs

Captures Neon's recommendations (markdown alternates at .md URLs,
hierarchical llms.txt, link rel=alternate, breadcrumbs, related-docs,
helpful 404s, content negotiation), audits where our three docs sites
stand against each one, and proposes a phased rollout — Phase 1 covers
markdown alternates + 404 + alternate link + Vary headers in one PR
without touching content, Phase 2 generates llms.txt from nav.ts +
frontmatter descriptions, Phase 3 is breadcrumbs + related-docs + the
rest of the description backfill.

A read-through for discussion, not a commitment.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
… 404, headers

Phase 1 of notes/agent-readable-docs.md. Gives every docs page a .md URL
agents can fetch, advertises it from the HTML head, and adds the headers
prod actually needs to serve it correctly. No content changes.

- site/{dolt,doltlab,doltgres}/src/pages/[...slug].md.ts (new)
  Static endpoint that re-serves the raw Markdown source at the .md suffix
  alongside the HTML page. Same content file and same contentRouteSlug, so
  /docs/foo/bar and /docs/foo/bar.md always refer to the same source. Uses
  import.meta.glob with ?raw so the bytes match what's in src/content/.

- site/shared/layouts/DocsLayout.astro
  Add <link rel="alternate" type="text/markdown" href="<page>.md"> to the
  head of every content page. Skipped on the docs root since /docs.md
  isn't a useful URL.

- site/{dolt,doltlab,doltgres}/src/pages/404.astro
  Expand from the one-line "Back to home" message to a helpful page —
  links to home, mentions the in-page search (/), and explicitly tells
  readers about the .md alternate convention (append .md to any docs URL).

- site/{dolt,doltlab,doltgres}/_headers (new)
  Cloudflare Pages response headers. Vary: Accept on /docs/* (so caches
  differentiate HTML vs. Markdown for the same URL) and an explicit
  Content-Type: text/markdown + an hour of public caching on /docs/*.md
  (Cloudflare otherwise defaults .md to text/plain).

- site/{dolt,doltlab,doltgres}/package.json
  Hook cp _headers dist/_headers into each build script, next to the
  existing cp _redirects line.

- cypress/e2e/dolt/markdown-alternate.spec.ts (new)
  Verifies the .md endpoint returns 200 with the raw source (frontmatter
  intact), that the HTML head advertises the alternate, that nested paths
  work, and that unknown .md paths return 404.

- cypress/e2e/dolt/navigation.spec.ts
  Update the "renders the custom 404 page" assertion to match the new
  wording, and add coverage that the .md-alternate hint is on the page.

Verified: all three sites build clean (139 + 75 + 62 .md alternates),
markdown-alternate + navigation + dead-links specs all pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Same fix already landed for dolt's navigation.spec.ts — the
'Back to <site> documentation home' link text was dropped to just
'<site> documentation home' in the helpful-404 rewrite. Two stale
assertions hit CI on doltlab and doltgres. Also add coverage that the
.md-alternate hint shows up so we don't lose it later.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@tbantle22 tbantle22 merged commit 436e67a into dev Jun 2, 2026
7 checks passed
@tbantle22 tbantle22 deleted the neon-docs-lessons branch June 2, 2026 17:06
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.

1 participant