// Link-preview image for The Penguin Test: the four panels for the first selection, 1200 x 630. // CH= node penguins_og.mjs -> ../penguins/site/og.png import { chromium } from 'playwright-core'; import { fileURLToPath } from 'url'; import path from 'path'; const here = path.dirname(fileURLToPath(import.meta.url)); const b = await chromium.launch({ executablePath: process.env.CH }); const p = await b.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 }); await p.goto('file://' + path.join(here, '../penguins/site/index.html')); await p.addStyleTag({ content: `.intro,.bar,.legend,.after,footer,.ro,.ph p{display:none!important} .top{padding-block:22px 0}.sub{font-size:16px}.grid{grid-template-columns:repeat(4,minmax(0,1fr))!important;padding-block:16px 0} .cap{font:500 17px/1.5 Inter,sans-serif;color:#9badc6;padding:14px 16px 0;max-width:1200px;margin:0 auto}.cap b{color:#ff4d5e;font-weight:600}.cap.big{font:600 21px/1.4 'Space Grotesk',Inter,sans-serif;color:#e8f0fb;padding-top:18px}` }); await p.evaluate(() => { const c = document.createElement('p'); c.className = 'cap'; const n = [...document.querySelectorAll('.panel')].map(x => x.querySelector('[data-f="n"]').textContent.match(/^\d+ of \d+/)[0]); c.innerHTML = `Emperor penguins, Pointe Géologie, 2005 · beyond a penguin's speed: globe ${n[0]}, North-pole AE ${n[1]}`; document.querySelector('.grid').after(c); const t = document.createElement('p'); t.className = 'cap big'; const r = document.querySelector('.after p').textContent.match(/Of the ([\d,]+) tracks.*?North-pole AE map ([\d,]+) \((\d+%)\) do, on Mercator ([\d,]+) and on the dual-pole AE map ([\d,]+)/); t.innerHTML = `All ${r[1]} tested tracks: globe 0 beyond the limit · North-pole AE ${r[2]} (${r[3]}) · Mercator ${r[4]} · dual-pole AE ${r[5]}`; c.after(t); window.dispatchEvent(new Event('resize')); }); await p.waitForTimeout(900); await p.screenshot({ path: path.join(here, '../penguins/site/og.png'), clip: { x: 0, y: 0, width: 1200, height: 630 } }); await b.close();