Skip to content

Commit 6f6d6b8

Browse files
committed
Add chapter 5 visual aid image to assets, new script for watching yaml for changes
1 parent c420450 commit 6f6d6b8

20 files changed

Lines changed: 285 additions & 89 deletions

.github/scripts/watch-comic.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
#!/usr/bin/env node
2+
/**
3+
* Watch visual-quickstart/content.yaml and rebuild the comic site on every save.
4+
*
5+
* Usage:
6+
* npm run watch:comic
7+
*
8+
* Leave this running while you edit content.yaml. Each time you save the file,
9+
* the comic HTML/CSS is regenerated automatically (same as `npm run build:comic`).
10+
* Press Ctrl+C to stop.
11+
*
12+
* Zero dependencies: uses Node's built-in fs.watch. It watches the directory and
13+
* filters for content.yaml so it keeps working across atomic "save = replace file"
14+
* editors (where the file is briefly renamed/recreated).
15+
*/
16+
17+
const { spawn } = require('child_process');
18+
const { watch, existsSync } = require('fs');
19+
const { join } = require('path');
20+
21+
const repoRoot = join(__dirname, '..', '..'); // .github/scripts -> repo root
22+
const docsDir = join(repoRoot, 'visual-quickstart');
23+
const contentFile = join(docsDir, 'content.yaml');
24+
const buildScript = join(__dirname, 'build-comic.js');
25+
const WATCHED = 'content.yaml';
26+
const DEBOUNCE_MS = 200;
27+
28+
if (!existsSync(contentFile)) {
29+
console.error(`\u2716 Content file not found:\n ${contentFile}`);
30+
process.exit(1);
31+
}
32+
33+
let building = false;
34+
let pending = false;
35+
let timer = null;
36+
37+
function runBuild() {
38+
if (building) {
39+
pending = true; // a change arrived mid-build; rebuild once this one finishes
40+
return;
41+
}
42+
building = true;
43+
const child = spawn('node', [buildScript], { stdio: 'inherit' });
44+
child.on('exit', (code) => {
45+
building = false;
46+
if (code === 0) {
47+
console.log(`\u2713 Rebuilt at ${new Date().toLocaleTimeString()} \u2014 watching for changes\u2026`);
48+
} else {
49+
console.error(`\u2716 Build failed (exit ${code}) \u2014 fix the error and save again.`);
50+
}
51+
if (pending) {
52+
pending = false;
53+
runBuild();
54+
}
55+
});
56+
}
57+
58+
function scheduleBuild() {
59+
clearTimeout(timer);
60+
timer = setTimeout(runBuild, DEBOUNCE_MS);
61+
}
62+
63+
console.log(`Watching ${contentFile}\nPress Ctrl+C to stop.`);
64+
runBuild(); // build once on startup so output is fresh
65+
66+
watch(docsDir, (_event, filename) => {
67+
if (filename === WATCHED) scheduleBuild();
68+
});
69+
70+
process.on('SIGINT', () => {
71+
console.log('\nStopped watching.');
72+
process.exit(0);
73+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"verify:gifs": "node .github/scripts/verify-gifs.js",
1111
"copy:content-engine": "node .github/scripts/copy-content-engine-files.js",
1212
"build:comic": "node .github/scripts/build-comic.js",
13+
"watch:comic": "node .github/scripts/watch-comic.js",
1314
"generate:demos": "npm run create:tapes && npm run generate:vhs && npm run verify:gifs",
1415
"release": "npm run generate:demos",
1516
"release:ci": "npm run generate:headers"

visual-quickstart/assets/css/style.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ body.home{display:flex;flex-direction:column;min-height:100vh}
9292
display:flex;flex-direction:column}
9393
.home-intro{margin:6px 0 0}
9494
.home-intro .cap{text-align:center;padding-left:0;font-size:1.12rem}
95-
.intro-cta{position:absolute;left:50%;bottom:30px;transform:translateX(-50%);z-index:3}
95+
.intro-cta{text-align:center;margin:24px auto 0}
9696
.intro-cta .cta{border:3px solid #fff;box-shadow:0 10px 24px rgba(0,0,0,.40)}
9797
.intro-cta .cta:hover{transform:translateY(-2px)}
9898
.cta{display:inline-block;background:var(--orange);color:#fff;text-decoration:none;
800 KB
Loading
752 KB
Loading
1.72 MB
Loading
913 KB
Loading
947 KB
Loading
739 KB
Loading
1.17 MB
Loading

0 commit comments

Comments
 (0)