Skip to content

fix(registry): include unsuffixed logos in index, add logo SVG API - #48

Merged
Railly merged 2 commits into
mainfrom
fix/logos-index-gap-and-svg-api
Aug 8, 2026
Merged

Railly merged 2 commits into
mainfrom
fix/logos-index-gap-and-svg-api

Conversation

@Railly

@Railly Railly commented Aug 8, 2026

Copy link
Copy Markdown
Member

The bug

logos-index.json was built with name.endsWith("-logo"). Every logo whose registry item name carries no suffix was skipped.

All 35 AWS service logos (aws-s3, aws-lambda, ...) were already published and reachable — /r/aws-s3.json returns 200 today — but they were absent from the index, so @tryelements/cli and anyone discovering through the index could not see them.

Fixing the filter surfaced 28 more individual logos (docker, figma, linear, resend, sentry, ...) that are typed registry:block rather than registry:ui, so type is not a usable discriminator either. The reliable signal is the logo category, excluding bundle items under _bundles/.

Index: 171 -> 206, which matches the 206 logo directories on disk exactly.

SVG generation

generate-svg-files.ts had the same suffix assumption, plus three real defects:

  • Broken output counted as success. amp, antigravity, codex and zep emitted raw JSX (d={ICON_PATH}, <GradientDef />). The script warned and wrote the file anyway. It now resolves module-level constants, string arrays rendered via .map(), and sub-components returning static JSX — and rejects anything still containing unresolved expressions instead of writing it.
  • Stale files. The output directory was never cleared, so renamed logos left orphans behind.
  • Drift. The list is now derived from logos-index.json, so the SVGs cannot diverge from the index.

All 377 emitted files validate as XML (xmllint), with no empty shapes.

Note the historical <slug>-logo.svg names are still written. /r/svg/anthropic-logo.svg currently returns 200 in production, so dropping those paths would have broken live URLs.

New API

The registry only ever served JSX, so any non-React consumer had to parse TypeScript to get a shape. That is why @tryelements/cli exists — this moves that extraction server-side.

GET /api/logos                          catalog (206)
GET /api/logos?name=aws-s3              SVG (default)
GET /api/logos?name=vercel&format=json  { viewBox, paths[], monochrome, svg }
GET /api/logos?name=vercel&format=dataurl
GET /api/logos/all                      whole catalog in one request
GET /api/logos/all?monochrome=true      31 recolorable logos

CORS is open and responses are cached, so <img src> and browser fetches work without a build step. Raster output is deliberately out of scope: it needs a rasterizer and per-request CPU, and SVG covers the cases we have.

Verification

  • 206 in the index, matching 206 directories
  • 377/377 SVGs valid XML, including the 4 that were previously broken
  • Every endpoint exercised against a running server: all three formats, bulk, 404, 400 on bad format, path traversal rejected, CORS and preflight
  • bun run typecheck and bun run build both pass

Railly added 2 commits August 7, 2026 22:06
The logos index was built with `name.endsWith("-logo")`, which silently
excluded every logo whose item name carries no suffix. All 35 AWS service
logos (aws-s3, aws-lambda, ...) were published and reachable but invisible
to logos-index.json and therefore to @tryelements/cli.

Filter on the `logo` category instead, excluding bundle items under
_bundles/. Type is not a reliable discriminator here: 28 individual logos
(docker, figma, linear, resend, ...) are typed registry:block.

Index: 171 -> 206, matching the 206 logo directories on disk.

SVG generation:
- Derive the list from logos-index.json so it cannot drift from the index
- Resolve module-level constants, string arrays rendered via .map(), and
  sub-components returning static JSX. amp, antigravity, codex and zep
  previously emitted raw JSX
- Reject output containing unresolved expressions instead of writing a
  broken file and counting it as a success
- Clear the output directory so removed logos leave no stale files, while
  still writing the historical `<slug>-logo.svg` names that are already
  published

All 377 emitted files validate as XML.

Add /api/logos returning a logo as svg, json (viewBox, paths, monochrome)
or dataurl, and /api/logos/all for the whole catalog in one request, so
non-React consumers do not have to parse the JSX component source.
@vercel

vercel Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
elements Building Building Preview Aug 8, 2026 1:07am

@Railly
Railly merged commit 047cd36 into main Aug 8, 2026
3 of 4 checks passed
@Railly
Railly deleted the fix/logos-index-gap-and-svg-api branch August 8, 2026 01:09
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