mirror of
https://github.com/jaronpate/folio.git
synced 2026-10-19 01:07:39 +00:00
More updates to resume script
This commit is contained in:
+21
-20
@@ -1,24 +1,25 @@
|
||||
import { chromium } from 'playwright';
|
||||
import { mkdir } from 'node:fs/promises';
|
||||
import { dirname, resolve } from 'node:path';
|
||||
import { fileURLToPath } from 'node:url';
|
||||
import { chromium } from 'playwright'
|
||||
import { mkdir } from 'node:fs/promises'
|
||||
import { dirname, join, resolve } from 'node:path'
|
||||
|
||||
const root = resolve(dirname(fileURLToPath(import.meta.url)), '..');
|
||||
const resumeHtml = resolve(root, 'public/resume/index.html');
|
||||
const root = join(import.meta.dir, '..')
|
||||
const resumeHtml = join(root, 'public/resume/index.html')
|
||||
const outputPath = resolve(
|
||||
process.argv[2] ?? resolve(root, 'public/resume/paper.pdf'),
|
||||
);
|
||||
Bun.argv[2] ?? join(root, 'public/resume/paper.pdf'),
|
||||
)
|
||||
|
||||
async function main() {
|
||||
await mkdir(dirname(outputPath), { recursive: true });
|
||||
await mkdir(dirname(outputPath), { recursive: true })
|
||||
|
||||
const browser = await chromium.launch();
|
||||
const page = await browser.newPage();
|
||||
const browser = await chromium.launch()
|
||||
const page = await browser.newPage()
|
||||
|
||||
await page.goto(`file://${resumeHtml}`, { waitUntil: 'networkidle' });
|
||||
await page.goto(Bun.pathToFileURL(resumeHtml).href, {
|
||||
waitUntil: 'networkidle',
|
||||
})
|
||||
await page.evaluate(async () => {
|
||||
await document.fonts.ready;
|
||||
});
|
||||
await document.fonts.ready
|
||||
})
|
||||
|
||||
await page.pdf({
|
||||
path: outputPath,
|
||||
@@ -30,13 +31,13 @@ async function main() {
|
||||
bottom: '0',
|
||||
left: '0',
|
||||
},
|
||||
});
|
||||
})
|
||||
|
||||
await browser.close();
|
||||
console.log(`Wrote ${outputPath}`);
|
||||
await browser.close()
|
||||
console.log(`Wrote ${outputPath}`)
|
||||
}
|
||||
|
||||
main().catch((error) => {
|
||||
console.error(error);
|
||||
process.exit(1);
|
||||
});
|
||||
console.error(error)
|
||||
process.exit(1)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user