Skip to content

Commit d3c7456

Browse files
committed
chore: generate screenshots with puppeteer
1 parent 489df61 commit d3c7456

File tree

8 files changed

+34
-11
lines changed

8 files changed

+34
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,4 @@ This theme makes no external connections, doesn't embed scripts, and is lightwei
6060

6161
## Preview
6262

63-
![Two screenshots of the Class theme for JSON Resume side-by-side. On the left-side, we see the light mode variant, while on the right-side is the dark mode variant.](./assets/preview.png)
63+
<img src="./assets/preview-light.png" width="49%" alt="The Class theme for JSON Resume rendered with mock data. Features a plain blue bar at the top containing the candidates name and role, then a plain white background with contact information, work experience, volunteer information, etc."/> <img src="./assets/preview-dark.png" width="49%" alt="The Class theme for JSON Resume rendered with mock data when dark mode is detected. Features a dark gray bar at the top containing the candidates name and role, then a slightly lighter gray background with contact information, work experience, volunteer information, etc."/>

assets/preview-dark.png

95.3 KB
Loading

assets/preview-light.png

94.6 KB
Loading

assets/preview.png

-6.08 MB
Binary file not shown.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"lint": "eslint .",
3232
"lint:fix": "eslint --fix .",
3333
"typecheck": "tsc --noEmit",
34+
"generate-preview": "node scripts/generate-preview.js",
3435
"build:pdf": "resume export --theme . --resume ./test/fixture.resume.json resume.pdf",
3536
"build:html": "resume export --theme . --resume ./test/fixture.resume.json resume.html"
3637
},
@@ -48,7 +49,8 @@
4849
"@types/node": "^24.8.1",
4950
"eslint": "^9.38.0",
5051
"eslint-plugin-import": "^2.32.0",
51-
"globals": "^16.4.0",
52+
"globals": "^14.0.0",
53+
"puppeteer": "^18.2.1",
5254
"resume-cli": "^3.1.2",
5355
"typescript": "^5.9.3"
5456
}

scripts/generate-preview.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import path from 'node:path';
2+
import puppeteer from 'puppeteer';
3+
import { render } from '../index.js';
4+
import resume from '../test/fixture.resume.json' with { type: 'json' };
5+
6+
const html = await render(resume);
7+
8+
const browser = await puppeteer.launch();
9+
const page = await browser.newPage();
10+
await page.setViewport({
11+
width: 779,
12+
height: 1054,
13+
});
14+
await page.setContent(html);
15+
await page.screenshot({
16+
path: path.join('assets', 'preview-light.png'),
17+
});
18+
await page.emulateMediaFeatures([
19+
{
20+
name: 'prefers-color-scheme',
21+
value: 'dark',
22+
},
23+
]);
24+
await page.screenshot({
25+
path: path.join('assets', 'preview-dark.png'),
26+
});
27+
await browser.close();

test/fixture.resume.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
},
2828
"work": [
2929
{
30-
"company": "JSON Resume",
30+
"name": "JSON Resume",
3131
"location": "Remote",
3232
"position": "Open Sourcerer 🧙‍♂️",
3333
"url": "https://jsonresume.org",

yarn.lock

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -218,10 +218,11 @@ __metadata:
218218
"@types/node": "npm:^24.8.1"
219219
eslint: "npm:^9.38.0"
220220
eslint-plugin-import: "npm:^2.32.0"
221-
globals: "npm:^16.4.0"
221+
globals: "npm:^14.0.0"
222222
handlebars: "npm:^4.7.8"
223223
html-minifier: "npm:^4.0.0"
224224
marked: "npm:^16.4.1"
225+
puppeteer: "npm:^18.2.1"
225226
resume-cli: "npm:^3.1.2"
226227
typescript: "npm:^5.9.3"
227228
languageName: unknown
@@ -2815,13 +2816,6 @@ __metadata:
28152816
languageName: node
28162817
linkType: hard
28172818

2818-
"globals@npm:^16.4.0":
2819-
version: 16.4.0
2820-
resolution: "globals@npm:16.4.0"
2821-
checksum: 10c0/a14b447a78b664b42f6d324e8675fcae6fe5e57924fecc1f6328dce08af9b2ca3a3138501e1b1f244a49814a732dc60cfc1aa24e714e0b64ac8bd18910bfac90
2822-
languageName: node
2823-
linkType: hard
2824-
28252819
"globalthis@npm:^1.0.4":
28262820
version: 1.0.4
28272821
resolution: "globalthis@npm:1.0.4"

0 commit comments

Comments
 (0)