ui improvements

This commit is contained in:
Daniel
2023-03-25 17:47:34 +03:30
parent 2e3ec53d2a
commit 3a5ae28f86
17 changed files with 117 additions and 55 deletions
+12 -2
View File
@@ -1,4 +1,5 @@
import { chromium, devices } from "playwright";
import { prisma } from "@/lib/api/db";
export default async (url: string, collectionId: number, linkId: number) => {
const archivePath = `data/archives/${collectionId}/${linkId}`;
@@ -12,9 +13,18 @@ export default async (url: string, collectionId: number, linkId: number) => {
await page.goto(url);
await page.pdf({ path: archivePath + ".pdf" });
const linkExists = await prisma.link.findFirst({
where: {
id: linkId,
},
});
await page.screenshot({ fullPage: true, path: archivePath + ".png" });
if (linkExists) {
await Promise.all([
page.pdf({ path: archivePath + ".pdf" }),
page.screenshot({ fullPage: true, path: archivePath + ".png" }),
]);
}
await context.close();
await browser.close();