Skip to content

Commit ffc1964

Browse files
refactor(utils/open-graph): replace puppeteer
1 parent 1c5d1b9 commit ffc1964

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

src/utils/open-graph/index.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { outputFile } from 'fs-extra';
33
import { compile } from 'handlebars';
44
import isInCi from 'is-in-ci';
55
import { join } from 'path';
6-
import { launch } from 'puppeteer';
6+
import { webkit } from 'playwright';
77

88
import { Routes, siteMetadata } from 'config/constants';
99

@@ -67,23 +67,16 @@ function compileTemplate({ title, authorName, type, width, height }: TemplatePro
6767
}
6868

6969
async function generateImage({ width, height, content }: Required<ImageProps>) {
70-
const browser = await launch({
70+
const browser = await webkit.launch({
7171
headless: true,
72-
args: ['--no-sandbox'],
73-
defaultViewport: {
74-
width,
75-
height,
76-
},
7772
});
7873

7974
const page = await browser.newPage();
8075
page.setDefaultTimeout(0);
8176
page.setDefaultNavigationTimeout(0);
82-
83-
await page.setContent(content, { waitUntil: 'networkidle2' });
84-
await page.waitForSelector('#body', {
85-
visible: true,
86-
});
77+
await page.setViewportSize({ width, height });
78+
await page.setContent(content);
79+
await page.waitForSelector('#body', { state: 'visible' });
8780

8881
const image = await page.screenshot();
8982
await browser.close();

0 commit comments

Comments
 (0)