~ knotless Search/
↑↓ move↵ open⇧↵ all results

johnandersen777.bsky.social/knotless

git that lives in your Atmosphere account

Forked from chadtmiller.com/knotless

0
0
25 lines · 1.0 KB Raw History
// Draws the images from src/ at the sizes they are published. Pass a directory
// to draw into it instead of over the committed files.
import { chromium } from 'playwright';
import { mkdirSync } from 'node:fs';
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';

const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
const out = resolve(process.argv[2] ?? root);
const images = [
  ['hero', 'atstore/hero.png', 1600, 900],
  ['hero-alt', 'atstore/hero-alt.png', 1600, 900],
  ['banner', 'bluesky/banner.png', 1500, 500],
];

const browser = await chromium.launch();
for (const [name, path, width, height] of images) {
  const page = await browser.newPage({ viewport: { width, height }, deviceScaleFactor: 2 });
  await page.goto(`file://${root}/src/${name}.html`, { waitUntil: 'networkidle' });
  await page.evaluate(() => document.fonts.ready);
  mkdirSync(dirname(`${out}/${path}`), { recursive: true });
  await page.screenshot({ path: `${out}/${path}` });
  await page.close();
}
await browser.close();