Publish the examples as markdown, and link it from each page - #179
Merged
Conversation
The catalog was JSON, and the document an agent actually reads was built from it inside the docs MCP server. That put the rendering behind one consumer: an agent handed an example's URL, or landing on the page from a search, had no way to reach the same text -- and a static host cannot render it on demand. So the rendering moves here. `bin/lib/render.mjs` emits `/catalog/<name>.md` and `/catalog/index.md` next to the JSON, and every example page points at its own with `rel="alternate"`, the way this generator's sites already point at `llms.txt`. The MCP server now passes those documents on verbatim, which is ~470 fewer lines there and, more to the point, one rendering instead of two that could drift. The JSON stays: it is the structured form -- dependencies as a map, sizes as numbers -- and the step the markdown is built from. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
The catalog was JSON, and the document an agent actually reads was assembled from it inside the docs MCP server (pmndrs/docs#562). That put the rendering behind one consumer.
An agent handed an example's URL — pasted into a chat, arrived at from a search, run by a vendor with no pmndrs plugin — gets HTML and has no route to the same text. And this site is
output: "export", so it cannot render one on demand.So the rendering moves here, where it can be published.
What
bin/lib/render.mjsemits, next to the JSON:/catalog/index.md— the whole gallery, one line per demo/catalog/<name>.md— one demo in full: facts, asset attribution, then each source file fencedand every example page points at its own, the way this generator's sites already point at
llms.txt:The gallery index is linked site-wide from the layout — as a literal
<link>rather than page metadata, since a page's ownalternatesreplaces the layout's field rather than merging with it.The MCP server now passes these on verbatim (pmndrs/docs#563): ~470 fewer lines there, and one rendering instead of two that could drift apart.
The JSON stays
It is the structured form — dependencies as a map, sizes as numbers — and it is the step the markdown is built from. Nothing consumes it today, which is also why it carries no
$schema: a schema for an artifact with no reader is maintenance for a reader that may never come. Worth adding the day something parses it, when its needs are known.Notes
catalog_urljoinswebsite_url/embed_urlinlib/helper.ts, so URL derivation stays in one place;catalogIndexUrlis exported for the layout, which has no per-example port to resolvebin/lib/**added towebsite#build3inputs, with atest/turbo-cache.test.tscase pinning it — a cache hit that skipped the renderers would serve documents describing examples that have since changedtest/render.test.tscovers what the docs repo used to: the size marker, the title elision, fences long enough to survive backticks inside a file, and attributionVerification
pnpm exec vitest run— 34 passing (17 render, 17 turbo cache)pnpm lint,pnpm format:checkBASE_PATH/BASE_URLset: 336 files inout/catalog/, and both<link rel="alternate">render with absolute URLs on an example page, the index alone on the home pageEXAMPLES_URL—examples://indexreturns 167 lines,get_example("spotlight-shadows")returns the published document including its attribution, a traversal name is refused🤖 Generated with Claude Code