Skip to content

feat(api-reference): show each tag's operations as cards - #415

Merged
nickvigilante merged 4 commits into
mainfrom
vigilante/api-tag-page-cards
Nov 30, 2026
Merged

nickvigilante merged 4 commits into
mainfrom
vigilante/api-tag-page-cards

Conversation

@nickvigilante

@nickvigilante nickvigilante commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Merge order

Independent now. It was stacked on #414, which has merged, and this branch has been rebased onto main.

Summary

Each REST API tag page now shows its operations as cards, the same cards as the landing page: the title as a link, the coloured verb badge, the route (the API path, in a code span that wraps instead of overflowing), the first sentence of the description if any, and the Deprecated label from #414, with deprecated operations last. The main landing cards now show the route too, so every card has title, verb and route. No group headings, grouping, filtering or sorting were added; a tag with many operations is one list of cards. No URL changes, and the operation count and sidebar are unchanged.

Design

Two approaches were compared. (a) Emit the list inside <div class="cards"> for remark-coder-cards. That would also change the Markdown twin and llms.txt, which are built from the page source, and it would give a plain code verb with no coloured badge and no Deprecated label, so the card would differ from the landing's. (b) Keep the plain Markdown list in the page source and render the cards from the landing data in the page-body hook. The twin and llms.txt keep the list, and the card is the one component both pages use. I chose (b).

The hook swaps the page body at render time (replace), as the schemas page already does, so the list is removed from the rendered HTML by the renderer, not hidden by CSS. The data contract gains path on each landing operation and, on each section, route (the tag page) and description. A tag page whose route matches no section keeps its Markdown, so data written before this change renders as before.

Trade-off for maintainers: because the body is replaced, the tag's description is carried in the data as plain paragraphs and shown above the cards, so inline Markdown in a tag description (links, emphasis) shows as plain text on the rendered tag page. The Markdown twin keeps the formatting. Coder's tag descriptions are short plain sentences today.

QA

Production still shows the old list until the engine is republished, so use the preview. Steps work in Chrome and Firefox; the Firefox steps are not verified.

  1. Open the preview of /reference/api/workspaces/. Expect the line "Create, list, and manage workspaces." and then two cards, with no bulleted list underneath: "List workspaces GET" with /api/v2/workspaces, and "Create user workspace by organization POST" with a "Deprecated" label and its route, last.
  2. Narrow the window to phone width (or use the browser's responsive mode). Expect long routes to wrap inside the cards with no horizontal scrollbar on the page.
  3. Press Tab through the page. Expect a visible focus ring around each card as it is focused, and Enter to open that operation's page.
  4. Open /reference/api/chats/. Expect one list of cards (no group headings), the deprecated ones last, each with its verb and route.
  5. Open /reference/api/. Expect each landing card to show the route under its title as well.
  6. On a tag page, use the page's Copy Markdown action (or add the Markdown extension to the URL, per the site's convention). Expect the Markdown to still list every operation as - [Title](./tag/slug.md): \VERB /path``.

Pages to compare

What to check Production Preview
Workspaces tag page https://coder.com/docs/reference/api/workspaces/ Branch alias from the docs preview comment, /docs/reference/api/workspaces/
Chats tag page (many operations) https://coder.com/docs/reference/api/chats/ Branch alias from the docs preview comment, /docs/reference/api/chats/
REST API landing https://coder.com/docs/reference/api/ Branch alias from the docs preview comment, /docs/reference/api/

The preview alias always serves the PR's latest deploy and needs a Vercel login.

Testing

New tests were written first. The generator tests (path, route, description, and the tag page source still holding the Markdown list) failed before the generator change; the render tests cover the tag page cards (title, verb text, route text, Deprecated label on the last card, no second list, links unchanged, non-tag pages untouched) and the route on landing cards. They use the fixture swagger's Workspaces tag with its deprecated operation. The Markdown twin and llms.txt come from the page source, which the generator test pins. Tests pass in docs-build, docs-next, docs-config, apps/docs and apps/offlinedocs, and typecheck, Oxfmt and Oxlint pass. /reference/api/workspaces is added to the axe page list; fixtures/url-parity-approved.json needs no change because no URL changes. next build aborts under the local virtual-memory cap, so the fixture build checks and the axe pass could not run locally; CI runs them.

Upstream

No. This is Coder's own page layout and generated reference, not a generic Fumadocs bug or option.

https://linear.app/codercom/issue/DOCS-1909/show-rest-api-operations-as-cards-on-each-tag-page-with-verb-and-route


🤖 Built with AI assistance.

@linear-code

linear-code Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
DOCS-1909 Show REST API operations as cards on each tag page, with verb and route

The main REST API landing page shows a card per operation with its verb. The tag pages (/reference/api/<tag>/) are still a Markdown bullet list.

Do. Render the tag pages as cards too, each with the title, the verb and the route (path). Keep the Markdown list in the page's Markdown twin and llms.txt.

Not in this issue. Splitting long tags (Chats has 54 visible operations, Enterprise 107) into groups needs the grouping decision, which waits on the redirect review.

Done when. Every tag page shows cards with title, verb and route, and passes the axe pass.

Review in Linear

Base automatically changed from vigilante/api-deprecated-last to main November 25, 2026 18:24
A tag page listed its operations as a plain Markdown list, while the landing page showed them as cards. Both now render the same card: title, coloured method badge, route and description, with the Deprecated label on a deprecated operation, in the order the generator already sorts them.

The generator records each operation's path and each section's tag page route and description. The tag page's source keeps the Markdown list, so the Markdown twin and llms.txt still list the operations, and the render hook swaps the list for the cards. The tag page is added to the axe pass.

Assisted-by: AI
@nickvigilante
nickvigilante force-pushed the vigilante/api-tag-page-cards branch from 16a7477 to 6f376a2 Compare November 25, 2026 18:50
@nickvigilante
nickvigilante marked this pull request as ready for review November 30, 2026 18:22
@nickvigilante
nickvigilante requested a review from a team as a code owner November 30, 2026 18:22

@Jesswinters Jesswinters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No P0 or P1 issues found. The approach (b) is sound: the Markdown twin and llms.txt keep the list because the generator still writes it into the page source (pinned by the docs-build test). The cards are the same component on both pages. Each build rewrites the OpenAPI data (openapi-output.ts), so the new required path never meets stale data.

Checked at 6f376a2 on Node 26: pnpm install --frozen-lockfile, the package build, pnpm typecheck and pnpm lint pass. Tests pass in @coder/docs-build (200), @coder/docs-next (491) and @coder/docs-config (106).

Inline (P2 and below, none blocking):

  • P2: on a tag page the cards' <h3> titles follow the page <h1> with no <h2> between them. axe's heading-order reports this; it isn't enforced, so CI won't fail.
  • P3: the route and the first sentence join with no space in the text (copy and paste, reader mode, some screen readers).
  • P3: the paragraph text is used as the React key.

Not verified: the preview (behind Vercel SSO), the axe pass and the fixture next build (CI runs them), and the QA steps in a browser.

Generated with Coder Agents on behalf of @Jesswinters

Comment on lines +139 to +142
{tag.description?.split("\n\n").map((paragraph) => (
<p key={paragraph}>{paragraph}</p>
))}
<OperationCards operations={tag.operations} hrefFor={hrefFor} />

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P2, accessibility: each Card title is an <h3> (fumadocs-ui card.tsx). On the landing, a tag's <h2> comes before its cards. On a tag page they come straight after the page <h1>, so the outline skips a level, and axe's heading-order (best-practice, reported but not enforced here) flags /reference/api/workspaces. People who move by heading land on level 3 with no level 2 above it.

A visually hidden level-2 heading keeps the design unchanged (no visible group heading) and fixes the outline. The label is a suggestion:

Suggested change
{tag.description?.split("\n\n").map((paragraph) => (
<p key={paragraph}>{paragraph}</p>
))}
<OperationCards operations={tag.operations} hrefFor={hrefFor} />
{tag.description?.split("\n\n").map((paragraph, index) => (
<p key={index}>{paragraph}</p>
))}
<h2 className="sr-only">Endpoints</h2>
<OperationCards operations={tag.operations} hrefFor={hrefFor} />

(This also covers the key nit below.) If you take it, the tag-page test could assert h2.sr-only before the first card.

Generated with Coder Agents on behalf of @Jesswinters

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a visually hidden <h2 className="sr-only">Endpoints</h2> before the cards on tag pages, and the tag-page test now asserts it comes before the first card (39fd004).

replace: (
<>
{tag.description?.split("\n\n").map((paragraph) => (
<p key={paragraph}>{paragraph}</p>

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P3 nit: the key is the paragraph text, so a description with two identical paragraphs would produce duplicate keys and a React warning. The index is safe here because the list is static per render (the suggestion above uses it).

Generated with Coder Agents on behalf of @Jesswinters

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The paragraphs are keyed by index now (39fd004). The repo lints react/no-array-index-key, so there is a one-line oxlint-disable-next-line with the reason.

Comment on lines +37 to +40
<code className="coder-api-route">{operation.path}</code>
{operation.description ? (
<span className="coder-api-card-text">{operation.description}</span>
) : null}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P3: display: block separates the route and the sentence on screen, but the text has no space between them. The new test pins "/api/v2/users/{user}Returns one user.". That joined string is what copy and paste, reader mode and some screen readers get. A space between the two costs nothing visually:

Suggested change
<code className="coder-api-route">{operation.path}</code>
{operation.description ? (
<span className="coder-api-card-text">{operation.description}</span>
) : null}
<code className="coder-api-route">{operation.path}</code>
{operation.description ? (
<>
{" "}
<span className="coder-api-card-text">{operation.description}</span>
</>
) : null}

The test's expected text would then be "/api/v2/users/{user} Returns one user.".

Generated with Coder Agents on behalf of @Jesswinters

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Added a space between the route and the description in the shared card markup, so the landing and tag pages match, and the test expects "/api/v2/users/{user} Returns one user." (39fd004).

On a tag page the card titles are h3s that followed the page h1, so the outline skipped a level. A visually hidden h2 fixes that without changing the design.

The route and the first sentence of a card had no space between them in the text, which is what copy and paste, reader mode and some screen readers see. The tag description paragraphs are now keyed by index, since identical paragraphs made duplicate keys.

Assisted-by: AI
@vercel

vercel Bot commented Nov 30, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
coder-docs Skipped Skipped Nov 30, 2026 7:06pm UTC

Request Review

The Markdown link pattern in the plain-text conversion is quadratic, and operation descriptions were already cut to 2000 characters first. Tag descriptions skipped that bound, so a spec with one huge paragraph could burn build CPU.

Each tag paragraph is now cut to the same 2000 characters, and at most 20 paragraphs are kept. The limits are shared constants, so both conversions use one value.

Assisted-by: AI

@Jesswinters Jesswinters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I found no P0 or P1 issues, so I'm approving. My three earlier comments are fixed in 39fd004: the sr-only level-2 heading before the cards, the paragraph keys, and the space between the route and the description.

I checked this locally on 39fd004. Tests pass in @coder/docs-build (200/200), @coder/docs-next (491/491), @coder/docs-config (106/106) and @coder/docs-theme (37/37). Typecheck is clean, oxlint reports 0 warnings and oxfmt --check passes.

Before merging: the CI run on 39fd004 (run 46487152214) was cancelled after about 6 minutes. That cancelled axe accessibility pass and packages on node 22, so build & check failed. You said the axe pass and the fixture build can only run in CI, and the axe pass is the only check on the new /reference/api/workspaces page entry. Please re-run it and get a green result first.

I left one P2 inline. It agrees with the Vercel security note.


This review was generated by Coder Agents on behalf of @Jesswinters.

function plainParagraphs(markdown: string | undefined): string | undefined {
const text = markdown
?.split(/\n\s*\n/)
.map(inlineMarkdownText)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

P2: tag descriptions reach the link regex with no length limit. firstSentence cuts its input to 2000 characters because the link pattern in inlineMarkdownText is quadratic. plainParagraphs sends the whole tag description through the same pattern with no cut. A Swagger file whose tag description has a long run of [x]( with no closing ) can therefore burn build CPU on preview and export builds. Coder's own tags are short, so this is low risk, but this is the one new place that takes text from the document without a bound.

The simplest fix is to cap the description before it is split, the same way firstSentence does. For example, markdown?.slice(0, 10_000) keeps any real tag description whole. A test with a long [x]( run would pin it down. Another option is to make the link pattern linear, for example by excluding ( inside the URL part, so both callers are safe.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Already covered by 7a8ebd8: each tag paragraph is cut to 2000 characters (the cap firstSentence uses) and at most 20 paragraphs are kept before inlineMarkdownText runs, so the regex input is bounded to 40,000 characters in total, tighter than the 10,000-per-description suggestion for any single run. The long-run case is pinned by the test added in that commit in openapi-reference.test.ts.

The single-version e2e job failed on a dropped connection while syncing the corpus, and the previous run was cancelled, so the head had no green run. No code changes.

Assisted-by: AI
@nickvigilante
nickvigilante merged commit dcbff89 into main Nov 30, 2026
37 of 40 checks passed
@nickvigilante
nickvigilante deleted the vigilante/api-tag-page-cards branch November 30, 2026 19:15

@Jesswinters Jesswinters left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

No P0 or P1 issues found. The inline P2/P3 suggestions are optional.

Generated with Coder Agents on behalf of @Jesswinters

This branch is waiting to be deployed

1 inactive and 1 waiting deployments
docs-preview — 3ba45daa Waiting Nov 30, 2026 by nickvigilante via preview / deploy preview #141
Preview — 3ba45daa Deployed Nov 30, 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