Browse Source

gen-screenshot: replace deno-puppeteer with Astral

deno-puppeteer has not been updated since 2022,
and I am having trouble running it.
dev
D. Bohdan 7 months ago
parent
commit
19af51fcd4
  1. 14
      gen-screenshot.ts

14
gen-screenshot.ts

@ -3,7 +3,7 @@
// To install the dependencies on Debian/Ubuntu:
// $ sudo apt install imagemagick optipng
import puppeteer from "https://deno.land/x/puppeteer@16.2.0/mod.ts";
import { launch } from "https://deno.land/x/astral@0.3.5/mod.ts";
const templateFile = "screenshot-page.html";
const temporaryFile = "temp.html";
@ -15,13 +15,13 @@ const slugify = (str: string) =>
.replace(/(^-|-$)/g, "");
const saveScreenshot = async (src: string, dest: string) => {
const browser = await puppeteer.launch({
defaultViewport: { width: 1024, height: 1024, deviceScaleFactor: 1 },
});
const page = await browser.newPage();
const browser = await launch();
await page.goto(src);
await page.screenshot({ fullPage: true, path: dest });
const page = await browser.newPage(src);
await page.setViewportSize({ width: 1024, height: 1024 });
const screenshot = await page.screenshot({ captureBeyondViewport: true });
await Deno.writeFile(dest, screenshot);
await browser.close();
};

Loading…
Cancel
Save