diff --git a/README.md b/README.md index 6e70174..03fbab3 100644 --- a/README.md +++ b/README.md @@ -14,3 +14,5 @@ npm run preview # sirve dist/ Comprobaciones: `npm run verificar:prohibidas`, `npm run verificar:metricas`, `node scripts/capturas.mjs "/,/proyectos"`. +Imagen Open Graph: `node scripts/og.mjs` regenera `public/img/og.png` con las +fuentes del sitio. diff --git a/public/img/og.png b/public/img/og.png index b561d66..e21d689 100644 Binary files a/public/img/og.png and b/public/img/og.png differ diff --git a/scripts/og.mjs b/scripts/og.mjs new file mode 100644 index 0000000..0416d07 --- /dev/null +++ b/scripts/og.mjs @@ -0,0 +1,47 @@ +// Genera public/img/og.png (1200×630) con las fuentes del sitio usando Playwright. +// Uso: node scripts/og.mjs +import { chromium } from 'playwright'; +import { fileURLToPath } from 'node:url'; +import path from 'node:path'; +import { mkdtempSync, writeFileSync, rmSync } from 'node:fs'; +import os from 'node:os'; + +const raiz = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..'); +const fuentes = path.join(raiz, 'public', 'fonts'); +const html = `
+

CollinaSystems

+

Sistemas para la operación: ventas, inventario, cobranza, flotillas, contratos, estaciones de servicio, personal.

+
collinasystems.com.mx
+ +
`; + +const browser = await chromium.launch(); +const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 }); +// Se abre como archivo para que las fuentes file:// carguen (desde about:blank no se permite). +const tmp = mkdtempSync(path.join(os.tmpdir(), 'og-')); +const archivo = path.join(tmp, 'og.html'); +writeFileSync(archivo, html); +await page.goto('file://' + archivo, { waitUntil: 'load' }); +await page.evaluate(() => + Promise.all([ + document.fonts.load("700 92px 'Fraunces'"), + document.fonts.load("600 22px 'Instrument Sans'"), + document.fonts.load("400 34px 'Instrument Sans'"), + document.fonts.load("400 24px 'JetBrains Mono'"), + ]).then(() => document.fonts.ready), +); +await page.screenshot({ path: path.join(raiz, 'public', 'img', 'og.png'), type: 'png' }); +await browser.close(); +rmSync(tmp, { recursive: true, force: true }); +console.log('public/img/og.png generado');