Kira

Software Engineering Student. Learning, Building, Thinking.

Latest Posts

About

I'm a software engineering student passionate about building thoughtful, well-crafted digital experiences. I write about what I'm learning, what I'm building, and the ideas shaping how I think about software and design.

This is my corner of the web — a place to share, reflect, and grow.

Blog

Thoughts on software, design, and the web.

Documentation

Customizing AstroFlareOG's Open Graph Image Templates

Open Graph Images

This theme generates OG images on Cloudflare Workers thanks to the cf-workers-og package by Jilles Soeters (GitHub: @jillesme).

Soeters' package uses @resvg/resvg-wasm with patched versions of satori and yoga-layout to perform its magic.

The image Response returned by the library includes Cache-Control headers so Cloudflare will cache them for a long time and minimize requests to the Worker.

Customizing Fonts

Web Fonts

AstroFlareOG uses the Astro Font Provider API to load and optimize web fonts for use in HTML and CSS. The theme uses the Atkinson family of variable fonts obtained from Fontsource.

Key files:

  • astro.config.ts — see fonts configuration
  • Layout.astro — renders <Font /> components
  • global.css — TailwindCSS theme registration

The Font Provider API has built-in support for Adobe, Bunny, Fontsource, Google, NPM, etc., plus the local src/assets/ directory.

Open Graph Image Fonts

Satori does not support variable fonts nor the WOFF2 format so a different font solution is necessary for OG image templates. Currently supported formats: *.woff, *.ttf, *.otf

cf-workers-og supports loading supported font formats from Custom Sources and Google Fonts. AstroFlareOG uses a Custom Source: supported non-variable *.woff versions of fonts from the Atkinson family are in the public/fonts/ directory.

@/lib/og/fonts.ts exports a loadLocalFont() utility that fetches the fonts via Cloudflare ASSETS binding.

Refer to cf-workers-og repo for more on Google Fonts:

Customizing Image Templates

See @/lib/og/*-template.ts files for the functions that generate the OG image templates as HTML templates. cf-workers-og also supports rendering React JSX for Astro projects that use React components.

There are many restrictions to observe with resvg and satori. Notable restrictions include inline styles, flexbox for layout, and a limited set of supported CSS properties and HTML elements.

Refer to project documentation: