Skip to content

Instantly share code, notes, and snippets.

@BeiXiao
BeiXiao / og_images.tmpl.tsx
Created September 17, 2024 17:52 — forked from hmans/og_images.tmpl.tsx
Automatic OpenGraph Images for Lume
import { render } from "https://deno.land/x/resvg_wasm@0.2.0/mod.ts";
import { Page, PageData } from "lume/core.ts";
import satori, { SatoriOptions } from "npm:satori";
/* We never want our beautiful PNGs to have a layout :-) */
export const layout = undefined;
/* Load fonts. We can't use variable fonts unfortunately. */
const inter = await Deno.readFile("./src/fonts/Inter-Regular.ttf");
const interBold = await Deno.readFile("./src/fonts/Inter-Bold.ttf");
@BeiXiao
BeiXiao / satori-google-fonts.jsx
Created September 17, 2024 17:50 — forked from trpfrog/satori-google-fonts.jsx
Satori で Google Fonts を使う
import satori from 'satori'
import fs from 'fs'
// fetch font information
const endpoint = new URL('https://www.googleapis.com/webfonts/v1/webfonts');
endpoint.searchParams.set('family', 'M PLUS Rounded 1c');
endpoint.searchParams.set('key', process.env.GOOGLE_FONTS_API_KEY);
const fontInfo = await fetch(endpoint).then(res => res.json());
// fetch font