20N: carrusel José Antonio y Lorca (propuesta); kit admite {{IMG:archivo}}
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01K9e6XVaQWrLD3vpXscNvs8
This commit is contained in:
parent
98fafe7b0e
commit
508fd41c24
11 changed files with 51 additions and 2 deletions
|
|
@ -2,7 +2,7 @@
|
|||
// Uso: node render.mjs spec.json
|
||||
// spec = { out: "dir", prefix: "nombre", footerLeft: "29N · VOTO EN BLANCO", numbered: true,
|
||||
// slides: [ { html: "<div class='txt'>...</div>", cross: 0.13, halo: false, footer: true } ] }
|
||||
// En el html se pueden usar {{LOGO}} y {{HORSE}} (data URIs) y las clases CSS de abajo.
|
||||
// En el html se pueden usar {{LOGO}}, {{HORSE}} y {{IMG:archivo}} (data URIs de assets/) y las clases CSS de abajo.
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
|
@ -98,7 +98,8 @@ const pg = await browser.newPage({ viewport: { width: 1080, height: H }, deviceS
|
|||
const n = spec.slides.length, files = [];
|
||||
for (let i = 0; i < n; i++) {
|
||||
const sl = spec.slides[i];
|
||||
const html = (sl.html || '').replaceAll('{{LOGO}}', LOGO).replaceAll('{{HORSE}}', HORSE);
|
||||
const html = (sl.html || '').replaceAll('{{LOGO}}', LOGO).replaceAll('{{HORSE}}', HORSE)
|
||||
.replace(/\{\{IMG:([^}]+)\}\}/g, (_, f) => `data:image/${f.endsWith('.png') ? 'png' : 'jpeg'};base64,` + asset(f));
|
||||
await pg.setContent(`<!doctype html><html><head><meta charset="utf-8"><style>${css}${spec.css || ''}</style></head><body><div class="s">${frame(i + 1, n, sl)}${html}</div></body></html>`);
|
||||
await pg.evaluate(() => document.fonts.ready); await pg.waitForTimeout(150);
|
||||
const f = path.join(out, `${spec.prefix || 'pnh'}${n > 1 ? '_' + (i + 1) : ''}.png`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue