Skip to content

Per-dataset OpenGraph images (auto-generated cards) #13

Closed

Description

@neuromechanist

Goal

Generate a unique OpenGraph/Twitter card image per dataset detail page so links shared on Slack, Twitter, BlueSky, Discord, mailing lists, etc. show a branded preview with dataset-specific info instead of a generic placeholder.

Target preview

A 1200x630 PNG showing, for each dataset:

  • Dataset short id (e.g., nm000104, on005262) — large mono
  • Dataset name (truncate to ~2 lines)
  • Modality badges (EEG / MEG / iEEG / EMG)
  • Participant count and total size
  • NEMAR wordmark + brain accent (consistent across all cards)
  • License chip if present
  • Subtle dark/teal gradient background (brand palette)

Implementation options

  1. Astro endpoint that renders SVG → PNG at the edge. Add src/pages/og/[id].png.ts that fetches the dataset metadata, composes a 1200x630 SVG, returns it as PNG. Heavy on Workers CPU but cacheable.
  2. Build-time generation. For static datasets, generate PNGs at build into public/og/<id>.png. Skips runtime cost but won't pick up newly published datasets without a rebuild.
  3. Satori (vercel/satori) for JSX → SVG. Lightweight, edge-runtime compatible, good typography. Closest to the recommended modern approach.
  4. Pre-render on dataset publish. When nemar-tools/nemar-cli publishes/updates a dataset, generate and upload the OG card to S3 (s3://nemar/<id>/og.png); the website just references it.

Lean toward (3) Satori or (4) pre-render. (3) gives flexibility, (4) gives lowest runtime cost.

Wire-up

After image generation lands, add per-page OG meta tags in src/pages/dataset/[id].astro:

```html







```

Add canonical URL + structured data (`schema.org/Dataset`) in the same pass.

Acceptance criteria

  • Sharing a dataset URL on Slack/Twitter shows the per-dataset card preview.
  • OG image fits 1200x630, <300 KB, renders within ~200 ms at the edge (option 1/3) or is served as a static asset (option 2/4).
  • Falls back gracefully if the dataset is missing fields.
  • Twitter card validator and Facebook sharing debugger both report no errors.

Related

  • Part of Phase 4 (Citation Dashboard + Community + Docs) or a polish item that ships ahead.
  • Depends on `getMetadata()` / `getDataset()` returning enough fields. Tasks/modalities backfill is tracked in nemar-cli#512.

Activity

  1. added
    enhancement
    on May 16, 2026
  2. neuromechanist commented on Jul 29, 2026

    @neuromechanist
    ContributorAuthor

    Shipped. Per-dataset OG cards are generated at build time and served from public/og/dataset/:

    • scripts/generate-og-images.mjs (bun run generate:og, wired into bun run build) plus scripts/generate-site-og-image.mjs for the site-level card
    • src/pages/og/dataset/[id].svg.ts and [id].png.ts for the on-demand path, src/lib/og-image.ts / og-chrome.ts for composition
    • A Pages deploy-hook cron (wrangler.og-cron.toml, bun run deploy:og-cron) regenerates cards so newly published datasets pick one up without a manual rebuild

    The generated PNGs are build artifacts, gitignored, not source.

    The canonical-URL + schema.org structured-data follow-up mentioned at the end of this issue is tracked separately in #156.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions