Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/en/blog.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html><html lang="en" data-lang="en"><head>
<meta charset="utf-8">
<link rel="icon" href="../favicon.svg" type="image/svg+xml">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#F6F1E8">

Expand Down
1 change: 1 addition & 0 deletions docs/en/case-redis-scan.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html><html lang="en" data-lang="en"><head>
<meta charset="utf-8">
<link rel="icon" href="../favicon.svg" type="image/svg+xml">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#F6F1E8">

Expand Down
1 change: 1 addition & 0 deletions docs/en/index.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html><html lang="en" data-lang="en"><head>
<meta charset="utf-8">
<link rel="icon" href="../favicon.svg" type="image/svg+xml">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#F6F1E8">

Expand Down
1 change: 1 addition & 0 deletions docs/en/skill.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<!doctype html><html lang="en" data-lang="en"><head>
<meta charset="utf-8">
<link rel="icon" href="../favicon.svg" type="image/svg+xml">
<meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover">
<meta name="theme-color" content="#F6F1E8">

Expand Down
202 changes: 164 additions & 38 deletions docs/game.html

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"type": "module",
"scripts": {
"build:en": "node scripts/build-en.mjs",
"check:failsafe": "node scripts/check-reveal-failsafe.mjs"
"check:failsafe": "node scripts/check-reveal-failsafe.mjs",
"check:en-assets": "node scripts/check-en-assets.mjs"
},
"devDependencies": {
"jsdom": "^25.0.1"
Expand Down
1 change: 1 addition & 0 deletions scripts/build-en.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ const ROOT_ASSETS = new Set([
'githire-analytics.js',
'i18n.js',
'game.html',
'favicon.svg',
]);

function rewriteRelativeAssets(doc) {
Expand Down
70 changes: 70 additions & 0 deletions scripts/check-en-assets.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// Regression guard for /en/ pages that are generated one directory below
// docs/. Root-level assets must be referenced with ../ so they do not resolve
// to missing /en/<asset> URLs.
//
// Run: npm run check:en-assets

import { existsSync, readFileSync } from 'node:fs';
import { dirname, join } from 'node:path';
import { fileURLToPath } from 'node:url';
import { JSDOM } from 'jsdom';

const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
const DOCS = join(ROOT, 'docs');
const EN = join(DOCS, 'en');

const pages = [
'index.html',
'blog.html',
'skill.html',
'case-redis-scan.html',
];

const rootAssets = new Set([
'favicon.svg',
'githire.css',
'githire-scroll.js',
'githire-analytics.js',
'i18n.js',
'game.html',
]);

let failed = 0;
const assert = (cond, msg) => {
console.log((cond ? '✓' : '✗') + ' ' + msg);
if (!cond) failed++;
};

for (const asset of rootAssets) {
assert(existsSync(join(DOCS, asset)), `root asset exists: docs/${asset}`);
}

for (const page of pages) {
const html = readFileSync(join(EN, page), 'utf8');
const dom = new JSDOM(html);
const doc = dom.window.document;
let checked = 0;

for (const el of doc.querySelectorAll('[href], [src]')) {
for (const attr of ['href', 'src']) {
const value = el.getAttribute(attr);
if (!value) continue;
if (/^([a-z]+:|\/\/|#|\/)/i.test(value)) continue;

const path = value.split('#')[0].split('?')[0];
if (rootAssets.has(path)) {
assert(false, `${page}: ${attr}="${value}" is a bare root asset`);
}
if (path.startsWith('../') && rootAssets.has(path.slice(3))) {
checked++;
assert(existsSync(join(EN, path)), `${page}: ${attr}="${value}" resolves to an existing asset`);
}
}
}
assert(checked > 0, `${page}: checked ${checked} rewritten root asset references`);
}

console.log(failed === 0
? '\nPASS — /en/ pages resolve root assets from the site root'
: `\nFAIL — ${failed} check(s) failed`);
process.exit(failed ? 1 : 0);