IKEA assembly, step by step: animated, manual-style 3D guides. Scan any paper manual with Together AI.
TypeScript
Drawing script: --missing draws only what isn't there yet
Youssef2c6ea4058d9e
diff --git a/scripts/og/render.mjs b/scripts/og/render.mjsindex 9e5384d..c531922 100644--- a/scripts/og/render.mjs+++ b/scripts/og/render.mjs@@ -1,7 +1,7 @@/*** Draws the pictures the share cards use, with the app's own engine:*- * npm run dev, then: node scripts/og/render.mjs [--base http://localhost:3000] [--only kallax-2x2]+ * npm run dev, then: node scripts/og/render.mjs [--base http://localhost:3000] [--only kallax-2x2] [--missing]** Needs Playwright from any project that has it: PLAYWRIGHT_FROM=/path/to/project.* Writes public/og/{slug}.png for the hand-picked catalog and public/og/kind-{kind}.png@@ -9,7 +9,7 @@*/import { createRequire } from "node:module";import { execFileSync } from "node:child_process";-import { mkdirSync, renameSync, writeFileSync } from "node:fs";+import { existsSync, mkdirSync, renameSync, writeFileSync } from "node:fs";import path from "node:path";const args = process.argv.slice(2);@@ -33,12 +33,14 @@ const step = arg("--step");const jobs = step? [{ slug: step.split(":")[0], mode: { kind: "step", index: Number(step.split(":")[1]) }, out: step.split(":")[2] }]: await page.evaluate(() => fetch("/dev/og/list").then((r) => r.json()));-const list = only ? jobs.filter((j) => j.slug === only || j.kind === only) : jobs;+const missing = args.includes("--missing");+const name = (j) => j.out ?? j.slug ?? "kind-" + j.kind;+const list = (only ? jobs.filter((j) => j.slug === only || j.kind === only) : jobs).filter((j) => !missing || !existsSync(path.join(OUT, `${name(j)}.png`)));let n = 0;for (const j of list) {const url = await page.evaluate((o) => window.__draw(o), { ...j, w: 640, h: 560 });if (!url) continue;- const file = path.join(OUT, `${j.out ?? j.slug ?? "kind-" + j.kind}.png`);+ const file = path.join(OUT, `${name(j)}.png`);writeFileSync(file, Buffer.from(url.split(",")[1], "base64"));// flatten onto pure white and keep 48 colours: line art stays crisp at a sixth of the sizeconst tmp = file + ".tmp.png";