Skip to content

feat: add .md support for LLMs#191

Merged
aboodman merged 3 commits intorocicorp:mainfrom
ceIia:feat/add-dot-md
Nov 6, 2025
Merged

feat: add .md support for LLMs#191
aboodman merged 3 commits intorocicorp:mainfrom
ceIia:feat/add-dot-md

Conversation

@ceIia
Copy link
Copy Markdown
Contributor

@ceIia ceIia commented Nov 4, 2025

what this does

this PR adds two main things:

  1. .md versions of all doc pages (e.g. /docs/introduction.md) via a rewrite to a /raw/[...slug]/route.ts.
  2. restructures the llms.txt approach to follow the standard "better" (at least from what i see is being done/what is outlined on llmstxt.org)

why i did this

i've been copying links to .md versions of docs from sites that support it (Next.js, Bun, Elysia, Knock, etc.) into Cursor constantly (basically add .md to the docs i need, and dump/paste it directly into Cursor or whatever AI i'm currently chatting with). most of the time, it's a way easier and optimized way to give context to the AI about what i'm working on than trying to explain something myself.

for example, i'm currently refactoring our synced queries implementation and kept needing to reference Zero docs, but there isn't an .md version, so it was either:

  • give the actual doc page (might pollute context/processing with other stuff),
  • explain it myself (slow, potentially inaccurate),
  • or use the raw .mdx file link from github directly (slightly slower, more clicks, but works).

how i got here with llms.txt

initially i just implemented the .md support (first commit). then @aboodman commented about the llms.txt file, which made me actually dig into how this is supposed to work.

turns out i'd been misunderstanding llms.txt this whole time. i thought the point was to dump your entire docs into a single massive file, which seemed odd for context windows. but after reading llmstxt.org, i realized the main llms.txt file is (i think?) actually meant to be a compact map/index that helps LLMs navigate to the specific pages they need. the llms-full.txt is the comprehensive version (still not sure exactly when you'd use it vs just following the links in the main file).

looking at how other projects do it:

they all follow this pattern: main file is a curated guide with links + descriptions, full version expands everything.

changes in this PR

commit 1: .md support

  • added route handler for [...slug]/route.ts that serves markdown versions of doc pages
  • handles both page.md and page/index.md patterns
  • uses the existing MDX to markdown conversion we had for llms.txt generation

commit 2: llms.txt improvements

  • restructured llms.txt to be a compact index following the llmstxt.org spec
  • llms-full.txt now includes full content from all docs in order (following routes-config order instead of filesystem order)
  • source URLs now appear between title and content in the full version for better readability
  • refactored shared utilities into lib/docs-utils.ts to avoid duplication

notes/questions

  1. should we link to .md versions in llms.txt? right now llms.txt links to the HTML pages. maybe it should link to the .md versions since that's more LLM-friendly? not sure what the convention is here.

  2. this entire llms.txt change might just be a huge skill issue, with me not understanding how to use llms.txt properly. maybe having one giant file is fine and i'm just doing it wrong? if so feel free to close this or cherry-pick just the .md commit.

  3. the build:llms command is now super ugly, i know, i'm sorry. i just couldn't figure out why ts-node/node/tsx hate me and ESM so much, so i just transpile the script on-the-fly instead, and execute it in the same command. is this ok? (oh Bun, how i miss you...)

examples of .md in action

@vercel
Copy link
Copy Markdown

vercel bot commented Nov 4, 2025

@ceIia is attempting to deploy a commit to the Rocicorp Team on Vercel.

A member of the Team first needs to authorize it.

@aboodman
Copy link
Copy Markdown
Contributor

aboodman commented Nov 4, 2025

Thank you for the contribution @ceIia! Are you aware of https://zero.rocicorp.dev/docs/llms? What does this PR achieve better/differently than that?

@ceIia
Copy link
Copy Markdown
Contributor Author

ceIia commented Nov 4, 2025

Thank you for the contribution @ceIia! Are you aware of https://zero.rocicorp.dev/docs/llms? What does this PR achieve better/differently than that?

just added a description to the PR, hopefully this explains things!

@ceIia ceIia marked this pull request as ready for review November 4, 2025 23:08
@vercel
Copy link
Copy Markdown

vercel bot commented Nov 6, 2025

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

Project Deployment Preview Comments Updated (UTC)
zero-docs Ready Ready Preview 💬 1 unresolved Nov 15, 2025 2:37am

@aboodman
Copy link
Copy Markdown
Contributor

aboodman commented Nov 6, 2025

just added a description to the PR, hopefully this explains things!

it does!

@aboodman
Copy link
Copy Markdown
Contributor

aboodman commented Nov 6, 2025

should we link to .md versions in llms.txt? right now llms.txt links to the HTML pages. maybe it should link to the .md versions since that's more LLM-friendly? not sure what the convention is here.

Seems like it.

I also think the content of the https://zero.rocicorp.dev/docs/llms page should change to describe the features, but I can do that eventually. Or you can in a subsequent PR. Whatever. Thanks a ton for this contribution, I love it!

"build": "npm run build:search && npm run build:llms && next build",
"build:search": "tsx lib/generateSearchIndex.ts",
"build:llms": "node generate-llms.js",
"build:llms": "npx --yes tsdown lib/generate-llms.ts --outDir dist --skipLibCheck && node dist/generate-llms.mjs",
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.

Perhaps since the .md files are runtime-generated, this root page should be too. It seems like we could use routes-config.ts directly at runtime to generate that root file rather than the build-time thing.

Copy link
Copy Markdown
Contributor

@aboodman aboodman left a comment

Choose a reason for hiding this comment

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

I'm going to land this now since it's useful to you as-is. There are a few follow-up things I think we should do. If you have time, that would be great. But don't feel pressured to – appreciate the contribution so far either way.

@aboodman aboodman merged commit 0027d59 into rocicorp:main Nov 6, 2025
2 checks passed
@ceIia ceIia deleted the feat/add-dot-md branch November 6, 2025 17:42
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