Skip to content

Isometric line figures that answer the pointer. For React and for anything with a DOM.

Site: the Open Graph card, a route photographed into a committed PNG

Lucas Marquesf5ebc93cdb49
diff --git a/apps/site/app/og/page.tsx b/apps/site/app/og/page.tsx
new file mode 100644
index 0000000..95bfd85
--- /dev/null
+++ b/apps/site/app/og/page.tsx
@@ -0,0 +1,21 @@
+import type { Metadata } from "next";
+import { Tile } from "@/components/tile";
+import { FIGURES } from "@/lib/figures";
+
+/** The Open Graph card, as a page: scripts/og.mjs photographs it at 1200 × 630 into public/og.png. */
+export const metadata: Metadata = { robots: { index: false } };
+
+export default function Og() {
+ return (
+ <main className="flex h-[630px] w-[1200px] items-center gap-14 overflow-hidden px-16">
+ <div className="w-[300px] shrink-0">
+ <h1 className="text-[56px] font-medium leading-none tracking-[-0.04em]">hairline</h1>
+ <p className="mt-5 text-[22px] leading-[1.35] text-muted">Six isometric line figures that answer the pointer.</p>
+ <p className="mt-8 font-mono text-[15px] text-ink">npm i @lucasmarkes/hairline</p>
+ </div>
+ <div className="grid flex-1 grid-cols-3 gap-4">
+ {FIGURES.map((doc, i) => <Tile key={doc.id} id={doc.id} index={i + 1} name={doc.name} />)}
+ </div>
+ </main>
+ );
+}
diff --git a/apps/site/public/og.png b/apps/site/public/og.png
new file mode 100644
index 0000000..15203a0
Binary files /dev/null and b/apps/site/public/og.png differ
diff --git a/scripts/og.mjs b/scripts/og.mjs
new file mode 100644
index 0000000..94569b8
--- /dev/null
+++ b/scripts/og.mjs
@@ -0,0 +1,33 @@
+#!/usr/bin/env node
+/**
+ * Photographs the site's /og route into apps/site/public/og.png, the Open
+ * Graph card. The result is committed; run this again when the figures or the
+ * card change.
+ *
+ * pnpm build && pnpm --filter @hairline/site start (in one terminal)
+ * node scripts/og.mjs [http://localhost:3000] (in another)
+ */
+import { createRequire } from "node:module";
+import { join, resolve } from "node:path";
+
+const ROOT = resolve(import.meta.dirname, "..");
+const SITE = join(ROOT, "apps/site");
+const { chromium } = createRequire(join(SITE, "package.json"))("@playwright/test");
+const base = (process.argv[2] ?? "http://localhost:3000").replace(/\/+$/, "");
+
+const browser = await chromium.launch({ channel: "chrome" });
+const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 2 });
+try {
+ await page.goto(`${base}/og`, { waitUntil: "networkidle" });
+} catch {
+ console.error(`Nothing at ${base}/og. Build and start the site first:\n pnpm build && pnpm --filter @hairline/site start`);
+ await browser.close();
+ process.exit(1);
+}
+await page.waitForFunction(() => document.querySelectorAll("[data-hairline] > svg > *").length >= 6 && document.fonts.status === "loaded");
+// Phosphor and Slow play on their own: give them a moment to be mid-loop.
+await page.waitForTimeout(1200);
+const out = join(SITE, "public/og.png");
+await page.screenshot({ path: out, clip: { x: 0, y: 0, width: 1200, height: 630 } });
+await browser.close();
+console.log(`wrote ${out}`);