20 lines
920 B
JavaScript
20 lines
920 B
JavaScript
// node render.cjs <html> <out-dir>: one PNG per [data-board] element, plus the full page (all.png).
|
|
// PW_MODULE = the absolute path of apps/app/node_modules/@playwright/test (the pinned Chromium).
|
|
const path = require('path')
|
|
const { chromium } = require(process.env.PW_MODULE)
|
|
;(async () => {
|
|
const [html, out] = process.argv.slice(2)
|
|
const browser = await chromium.launch()
|
|
const page = await browser.newPage({ viewport: { width: 1400, height: 900 }, deviceScaleFactor: 1 })
|
|
await page.goto('file://' + path.resolve(html))
|
|
await page.waitForLoadState('networkidle')
|
|
const boards = await page.$$('[data-board]')
|
|
for (const b of boards) {
|
|
const name = await b.getAttribute('data-board')
|
|
await b.screenshot({ path: path.join(out, name + '.png') })
|
|
}
|
|
await page.screenshot({ path: path.join(out, 'all.png'), fullPage: true })
|
|
await browser.close()
|
|
console.log('boards', boards.length)
|
|
})()
|