@json-render/image: pass extra options through to Satori

Open
#391 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
58/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript
Domain
backend

Research direction

Find the implementations of renderToSvg and renderToPng and inspect how they call Satori and define their options. Decide which pass-through approach the maintainers want, then check the existing render tests and add coverage for forwarding an option such as embedFont: false. Done means the chosen public API forwards Satori options without changing existing behavior.

Written by the indexing model from the issue text.

Description

renderToSvg and renderToPng call Satori with only width, height and fonts, so the rest of Satori's options aren't available.

My usecase is selectable text in SVGs. I'm using json-render in tsquare, which renders wireframes from text to SVG for docs and Notion. Satori's embedFont: false keeps text as <text> elements instead of outlines, so it can be selected and searched (for example, in a PDF). Today the only way to use it is to copy buildTree and call Satori directly.

The same pass-through would also cover non-Latin text and emoji. Satori draws a box for any character the given fonts don't cover, and its fix, loadAdditionalAsset (as in @vercel/og), can't be passed through either.

Would you accept either of these?

  1. An optional satori or satoriOptions field in the options, spread into the Satori call:
    renderToSvg(spec, { fonts, satori: { embedFont: false } })
    
  2. Exporting buildTree, so callers can run Satori themselves.

Happy to send a PR for whichever you prefer.

Dominant language
TypeScript
Stars
20k
Forks
1.1k
Avg merge
1d 18h
Merged PRs (30d)
25

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from vercel-labs/json-render

All issues in vercel-labs/json-render

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.