Skip to content

Commit cd98b4c

Browse files
committed
debug: expand OG image diagnostics, full-page screenshot (to be reverted)
1 parent 4d6cbf0 commit cd98b4c

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

pages/api/preview/[ranges].ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,26 @@ const handler = async (req: NextApiRequest, res: NextApiResponse) => {
8585
const diag = await page.evaluate(() => {
8686
const body = document.body;
8787
const rect = body.getBoundingClientRect();
88+
const sel = document.getSelection();
8889
return {
89-
bodyTextLength: body.innerText?.length ?? -1,
90+
bodyText: (body.innerText ?? '').slice(0, 200),
9091
bodyHTMLLength: body.innerHTML?.length ?? -1,
9192
scrollY: window.scrollY,
9293
bodyRect: { width: rect.width, height: rect.height },
9394
bodyBg: getComputedStyle(body).backgroundColor,
9495
fontsReady: document.fonts.status,
96+
hasFocus: document.hasFocus(),
97+
selRangeCount: sel?.rangeCount ?? -1,
98+
selIsCollapsed: sel?.isCollapsed,
99+
selAnchorTag: sel?.anchorNode?.parentElement?.tagName,
95100
};
96101
});
97102

98103
const result = await page.screenshot({
99104
type: 'png',
100105
encoding: 'binary',
101106
captureBeyondViewport: false,
107+
fullPage: true,
102108
});
103109

104110
await browser.close();

0 commit comments

Comments
 (0)