Skip to content

Commit

Permalink
resume with handlebars
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgraffis committed May 22, 2021
1 parent f9481c1 commit ad65a87
Show file tree
Hide file tree
Showing 35 changed files with 5,897 additions and 365 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules

# Local Netlify folder
.netlify
47 changes: 47 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
const puppeteer = require('puppeteer')
const fs = require('fs-extra')
const jsdom = require("jsdom");

async function buildPDF(html) {
const browser = await puppeteer.launch({ headless: true })
const page = await browser.newPage();
console.log('Opening puppeteer...')
await page.setContent(html, { waitUntil: 'networkidle0' })
console.log('Generating PDF...')
const pdf = await page.pdf({
format: 'A4',
displayHeaderFooter: false,
printBackground: true,
margin: {
top: '0.4in',
bottom: '0.4in',
left: '0.4in',
right: '0.4in',
}
})
await browser.close()
console.log('Saving file...')
fs.writeFileSync('./dist/resume.pdf', pdf)
console.log('Done')
return pdf
}

async function buildAll() {
const html = await fs.readFile('dist/index.html', 'utf8')
const css = await fs.readFile('dist/assets/index.4c84e427.css', 'utf8')
const dom = new jsdom.JSDOM(html)
dom.window.document.querySelector("head").innerHTML += `<style>
${css}
</style>`;
dom.window.document.querySelectorAll("a").target = '_blank'
dom.window.document.querySelectorAll("a").rel = 'noreferrer'
await fs.writeFile('dist/index.html', dom.serialize())
const newHTML = await fs.readFile('dist/index.html', 'utf8')
await buildPDF(newHTML)
console.log('done')
}

buildAll().catch(e => {
console.error(e)
process.exit(1)
})
1 change: 1 addition & 0 deletions dist/assets/index.3b565527.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions dist/assets/index.4c84e427.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit ad65a87

Please sign in to comment.