We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent dc743b6 commit e0d4b54Copy full SHA for e0d4b54
api/_lib/chromium.ts
@@ -0,0 +1,21 @@
1
+import { launch, Page } from 'puppeteer-core';
2
+import { getOptions } from './options';
3
+let _page: Page | null;
4
+
5
+async function getPage() {
6
+ if (_page) {
7
+ return _page;
8
+ }
9
+ const options = await getOptions(false);
10
+ const browser = await launch(options);
11
+ _page = await browser.newPage();
12
13
+}
14
15
+export async function getScreenshot(url, width, height) {
16
+ const page = await getPage();
17
+ await page.goto(url);
18
+ await page.setViewport({ width: width || 1920, height: height || 1080 });
19
+ const file = await page.screenshot({ 'png' });
20
+ return file;
21
0 commit comments