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