Skip to content

Commit

Permalink
Generate pdf on build.
Browse files Browse the repository at this point in the history
  • Loading branch information
theruther4d committed Jul 27, 2021
1 parent d8672f8 commit 05b6325
Show file tree
Hide file tree
Showing 4 changed files with 241 additions and 31 deletions.
12 changes: 8 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,11 @@
},
"scripts": {
"start": "REACT_APP_GITHUB_SECRET=\"$(< src/github.secret.txt)\" react-scripts start",
"build": "react-scripts build",
"build:local": "REACT_APP_GITHUB_SECRET=\"$(< src/github.secret.txt)\" react-scripts build",
"build": "react-scripts build && npm run pdf",
"build:local": "REACT_APP_GITHUB_SECRET=\"$(< src/github.secret.txt)\" react-scripts build && npm run pdf",
"test": "react-scripts test",
"eject": "react-scripts eject"
"eject": "react-scripts eject",
"pdf": "node scripts/pdf.js"
},
"eslintConfig": {
"extends": [
Expand All @@ -47,5 +48,8 @@
"last 1 safari version"
]
},
"devDependencies": {}
"devDependencies": {
"puppeteer": "^10.1.0",
"serve-handler": "^6.1.3"
}
}
29 changes: 29 additions & 0 deletions scripts/pdf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const puppeteer = require("puppeteer");
const { execSync } = require("child_process");
const http = require("http");
const handler = require("serve-handler");

const server = http.createServer((req, res) => {
return handler(req, res, {
public: "build",
});
});

(async () => {
server.listen(3000);

const browser = await puppeteer.launch();
const page = await browser.newPage();

await page.goto("http://localhost:3000", {
waitUntil: "networkidle2",
});

await page.pdf({
path: "build/josh-rutherford-resume.pdf",
format: "a4",
});

await browser.close();
server.close();
})();
3 changes: 1 addition & 2 deletions src/history/history.scss
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,7 @@ $horizontal_breakpoint: 724px;

@media print {
top: -1.5rem;
box-shadow: 0 4px 7px 1px rgba(black, 0.2),
0 16px 10px -12px rgba(black, 0.4);
box-shadow: none;
}

svg {
Expand Down
Loading

0 comments on commit 05b6325

Please sign in to comment.