feat: cv
This commit is contained in:
parent
4999423af4
commit
87019379d7
22 changed files with 441 additions and 166 deletions
10
scripts/build-cv.sh
Executable file
10
scripts/build-cv.sh
Executable file
|
|
@ -0,0 +1,10 @@
|
|||
#!/bin/bash
|
||||
mkdir -p dist
|
||||
thorium-browser \
|
||||
--headless=new \
|
||||
--no-sandbox \
|
||||
--disable-gpu \
|
||||
--virtual-time-budget=5000 \
|
||||
--align-pdf-default-print-settings-with-html \
|
||||
--print-to-pdf="dist/cv.pdf" \
|
||||
"http://localhost:5173/cv"
|
||||
41
scripts/build-cv.ts
Normal file
41
scripts/build-cv.ts
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
#!/usr/bin/env bun
|
||||
import { mkdir } from "node:fs/promises"
|
||||
import { dirname } from "node:path"
|
||||
import { chromium } from "playwright"
|
||||
|
||||
const url = "file:///finch/da.nfin.ch/dist/cv.html"
|
||||
const output = "dist/cv.pdf"
|
||||
|
||||
await mkdir(dirname(output), { recursive: true })
|
||||
|
||||
const executablePath =
|
||||
process.env.CHROMIUM_PATH ??
|
||||
Bun.which("thorium-browser") ??
|
||||
Bun.which("chromium") ??
|
||||
Bun.which("chromium-browser") ??
|
||||
Bun.which("google-chrome") ??
|
||||
undefined
|
||||
|
||||
const browser = await chromium.launch({
|
||||
executablePath,
|
||||
headless: true,
|
||||
args: ["--no-sandbox", "--disable-gpu"],
|
||||
})
|
||||
|
||||
try {
|
||||
const page = await browser.newPage()
|
||||
|
||||
await page.goto(url, {
|
||||
waitUntil: "networkidle",
|
||||
timeout: 30_000,
|
||||
})
|
||||
|
||||
await page.pdf({
|
||||
path: output,
|
||||
printBackground: true,
|
||||
displayHeaderFooter: false,
|
||||
preferCSSPageSize: true,
|
||||
})
|
||||
} finally {
|
||||
await browser.close()
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue