21 lines
2.4 KiB
JavaScript
21 lines
2.4 KiB
JavaScript
// Generate the PlotDirector social-sharing asset directly from the public editorial design.
|
||
const { chromium } = require('playwright');
|
||
const path = require('node:path');
|
||
const fs = require('node:fs');
|
||
(async () => {
|
||
const browser = await chromium.launch();
|
||
try {
|
||
const page = await browser.newPage({ viewport: { width: 1200, height: 630 }, deviceScaleFactor: 1 });
|
||
await page.setContent(`<!doctype html><html lang="en-GB"><meta charset="utf-8"><style>
|
||
*{box-sizing:border-box}body{margin:0;width:1200px;height:630px;background:#f8f5ee;color:#292c27;font-family:Georgia,serif;padding:62px 76px;position:relative;overflow:hidden}
|
||
.brand{font-weight:bold;font-size:33px;letter-spacing:-1px}.brand span{color:#a77d34}.eyebrow{font:600 11px system-ui;letter-spacing:3px;text-transform:uppercase;color:#65665b;margin:65px 0 24px}
|
||
h1{font-weight:400;font-size:74px;line-height:1.04;letter-spacing:-3px;margin:0;position:relative;z-index:1}em{color:#6b7655;font-weight:400}.rule{width:330px;height:5px;background:#e3b85e;transform:rotate(-2deg);margin:20px 0 27px}
|
||
p{font:20px/1.5 system-ui;color:#65665b;margin:0}.note{position:absolute;right:70px;top:210px;transform:rotate(7deg);width:230px;padding:30px;background:#f1d88d;box-shadow:4px 12px 25px #292c2712;font:italic 31px/1.35 Georgia}.note small{display:block;font:10px system-ui;letter-spacing:2px;text-transform:uppercase;margin-bottom:20px}
|
||
footer{position:absolute;bottom:40px;left:76px;right:76px;border-top:1px solid #d9d8cb;padding-top:15px;font:12px system-ui;letter-spacing:.5px;color:#65665b}
|
||
</style><div class="brand">PlotDirector<span>.</span></div><div class="eyebrow">A little order. A lot more story.</div><h1>You've got a<br />book to <em>finish.</em></h1><div class="rule"></div><p>You write it. PlotDirector remembers it.</p><div class="note"><small>A promise to the author</small>Your book.<br />Your words.</div><footer>plotdirector.com · For the stories only you can tell.</footer></html>`);
|
||
const image = await page.screenshot({ path: path.resolve(__dirname, '../../PlotLine/wwwroot/og-image.png') });
|
||
fs.writeFileSync(path.resolve(__dirname, '../../PlotLine/wwwroot/images/public/plotdirector-social.png'), image);
|
||
console.log('Created PlotDirector social image: 1200 × 630.');
|
||
} finally { await browser.close(); }
|
||
})().catch(error => { console.error(error); process.exitCode = 1; });
|