Logos and media
A logo is an object in the MEDIA bucket, and the row carries its key: the seed puts it there
from a dataset (pnpm db:seed:*, pnpm content:use), the submit form from an upload. A
production build serves it from media.baseUrl; a local build and pnpm dev serve it from the
local bucket through the /media/<key>/ route.
---name: Acmeurl: https://acme.comlogo: /logos/acme.svg---In a dataset, logo is an https:// URL or a /logos/<file> path in the dataset’s logos/
directory; ./acme.png, logos/acme.png and http:// are refused by the seed and the importer
before a row is written. No logo is a letter tile.

pnpm db:seed:local --with-images --with-favicons| Pass | Flag | Uploads |
|---|---|---|
| 1 | --with-images |
each https:// logo in the dataset |
| 2 | --with-favicons |
each listing without a key: its site’s icon |
| 3 | --with-images |
each /logos/<file> in the dataset |
db:seed — seed/datasets/ai-tools/listings → D1 (local) downloaded N/M logo(s); uploading to R2... stored N dataset logo URL(s) in R2 in 9s (not stored: unreachable=2) downloaded N/M favicon(s); uploading to R2... fetched N favicon(s) into R2 in 48s (no icon: unreachable=3, not-an-image=1) uploaded N /logos/ file(s) to R2 N listing(s), 0 click row(s) in K statement(s); largest B bytes (limit L)seeded N listing(s) into the local databaseThe first pnpm dev runs exactly this on an empty local database. --dry-run uploads nothing:
--with-images ignored in a dry run (nothing is uploaded, logo_key stays NULL).
public/favicon.svg is the browser icon, and the header mark through site.logo: '/favicon.svg';
replace the file or point site.logo at another path under public/.
pnpm og:default renders public/og-default.png; --check exits 1 when stale.
Verify
Section titled “Verify”| Where | You should see | |
|---|---|---|
| A seeded logo, locally | pnpm dev, then a listing page |
/media/logos/<id>.<ext>/ at 128 px; 48 px on the index |
| A seeded logo, in production | curl -sI https://<media host>/logos/<id>.png |
200, content-type: image/png, cache-control: public, max-age=300 |
| R2 in the build | pnpm check:config |
logos optimised from R2 (+1 webp each) |
| A submitted logo | /admin/listings/<id>/ |
the picture |
Worth knowing
Section titled “Worth knowing”- Favicon order:
<link rel="…icon…">tags,/apple-touch-icon.png,/apple-touch-icon-precomposed.png,/favicon.svg,/favicon.png,/favicon.ico. - Keys are
logos/<id>.<ext>(<id>derived from the slug when seeded, random for an upload), so a re-seed overwrites its own objects; deleting a listing says1 object in R2, deleted with the row. - A production build optimises each logo once (
<Image>, a 128 px webp) frommedia.baseUrl; a local build renders its/media/paths as plain<img>, and its OG images carry no logo. - Set
media.baseUrlto the bucket’s public host,https://with no trailing slash. - An upload over
limits.logoMaxBytes(512 KB, ceiling 1 MiB) is refused unread; the rest are sniffed by bytes, not by name — PNG, JPEG, WebP, SVG without<script>, ICO. - One warning per failure —
submit: uploaded logo rejected (too-large),submit: remote logo not stored (unreachable)— and a nulllogo_key; the submission is stored anyway.
When it is off or degraded
Section titled “When it is off or degraded”| Config state | The visitor sees | Fix |
|---|---|---|
media.baseUrl still https://media.example.com |
Failed to load remote image https://media.example.com/logos/<id>.png stops a production build; a local build is unaffected |
the bucket’s public host (pnpm cf:media), rebuild |
media.baseUrl on a non-bucket host |
the same; an SVG key is a broken-image box | a host where curl -sI answers 200 |
MEDIA binding missing |
a letter tile; the seed refuses: wrangler.jsonc has no r2_buckets entry bound as MEDIA; --with-images needs one |
add the r2_buckets entry; pnpm cf:setup creates the bucket |
A logo URL that 404s |
a broken-image box; the OG renderer logs [zerodirs:og] logo <url>: HTTP 404; using the initial-letter tile |
fix the URL or logo: null |
| An SVG on the media host | a plain <img>; converting would stop the build with UnsupportedImageFormat |
expected |
A logo over limits.logoMaxBytes |
rejected, then a letter tile; the seed counts it under too-large |
raise the limit or shrink it |
Configuration
Section titled “Configuration”media.baseUrl, limits.logoMaxBytes, limits.screenshotMaxBytes, site.logo and listing.screenshotMax — media, limits, site, listing. pnpm cf:media is what writes media.baseUrl; nothing else in the starter edits site.config.ts.
Directorysrc/
- content/schema.ts the
logorule - components/listing/Logo.astro the rendering point
- lib/media.ts
mediaUrl(),mediaRoutePath(),isOptimizableLogo() - server/media.ts sniffing,
putLogo(),fetchLogo() - lib/ico.ts ICO to PNG
- content/schema.ts the
- integrations/media.ts the
/media/[...key]route Directoryscripts/
- seed.ts the three upload passes
- favicon.ts the favicon fetcher
- og-default.ts
pnpm og:default
Directorypublic/
- favicon.svg the browser icon
- og-default.png the OG fallback
Directoryseed/datasets/
Directoryai-tools/logos/ the demo’s letter tiles
- …
- wrangler.jsonc the
MEDIAbinding