Skip to content

Commit 5b8e51a

Browse files
kt3kclaude
andcommitted
feat: generate per-repo og:image cards at build time
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent a3b314e commit 5b8e51a

10 files changed

Lines changed: 765 additions & 83 deletions

File tree

_config.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import date from "lume/plugins/date.ts";
33
import basePath from "lume/plugins/base_path.ts";
44
import tailwindcss from "lume/plugins/tailwindcss.ts";
55
import feed from "lume/plugins/feed.ts";
6+
import ogImages from "lume/plugins/og_images.ts";
67
import { parse as parseYaml } from "@std/yaml";
78

89
const site = lume({
@@ -17,6 +18,29 @@ site.use(date());
1718
site.use(tailwindcss());
1819
site.use(basePath()); // rewrites href/src in the output to include the base path
1920

21+
// Lume's _cache keys entries with WebCrypto MD5, which Deno 2.8 removed, so
22+
// every cache write throws. Disabling the cache only costs re-rendering the
23+
// og:image cards each build, which is fast. TODO: drop once Lume digests with
24+
// a supported algorithm.
25+
site.cache = undefined;
26+
27+
// Per-repo og:image cards (pages opt in via `openGraphLayout`; the repo tab
28+
// landing pages do — see src/repo-feeds.page.ts and src/_includes/og/repo.ts).
29+
const mulish = (weight: number) =>
30+
Deno.readFile(new URL(`./src/_fonts/mulish-${weight}.ttf`, import.meta.url));
31+
site.use(ogImages({
32+
options: {
33+
width: 1200,
34+
height: 630,
35+
fonts: [
36+
{ name: "Mulish", weight: 500, style: "normal", data: await mulish(500) },
37+
{ name: "Mulish", weight: 600, style: "normal", data: await mulish(700) },
38+
{ name: "Mulish", weight: 700, style: "normal", data: await mulish(700) },
39+
{ name: "Mulish", weight: 800, style: "normal", data: await mulish(800) },
40+
],
41+
},
42+
}));
43+
2044
// Expose the watched repo list (from repos.yml) to all templates.
2145
const reposDoc = parseYaml(await Deno.readTextFile("repos.yml")) as {
2246
repos?: (string | { repo: string })[];

0 commit comments

Comments
 (0)