mirror of
https://github.com/Abdess/retroarch_system.git
synced 2026-10-24 12:49:03 -05:00
generate_site.py --engine starlight writes the pages, navigation and data files of an Astro Starlight project in website/. Links resolve to site addresses, every heading keeps its MkDocs id, and pages split by size are measured in the MkDocs Markdown so both builds cut the same files. The 839 pages and their 45,613 ids match the MkDocs build.
25 lines
1.2 KiB
JavaScript
25 lines
1.2 KiB
JavaScript
// axe-core (WCAG 2.2 A/AA rules) in light and dark, one line per page and scheme.
|
|
// node axe.mjs <base url> <page>...
|
|
import { chromium } from 'playwright-core';
|
|
import { readFile } from 'node:fs/promises';
|
|
import { createRequire } from 'node:module';
|
|
|
|
const require = createRequire(import.meta.url);
|
|
const axeSource = await readFile(require.resolve('axe-core/axe.min.js'), 'utf8');
|
|
const [base, ...pages] = process.argv.slice(2);
|
|
const browser = await chromium.launch({ executablePath: '/usr/bin/google-chrome' });
|
|
for (const scheme of ['light', 'dark']) {
|
|
const context = await browser.newContext({ viewport: { width: 390, height: 844 }, colorScheme: scheme });
|
|
const page = await context.newPage();
|
|
for (const path of pages) {
|
|
await page.goto(new URL(path, base).href, { waitUntil: 'networkidle' });
|
|
await page.addScriptTag({ content: axeSource });
|
|
const result = await page.evaluate(() =>
|
|
window.axe.run(document, { runOnly: ['wcag2a', 'wcag2aa', 'wcag21a', 'wcag21aa', 'wcag22aa'] }));
|
|
const violations = result.violations.map((v) => `${v.id}(${v.nodes.length})`);
|
|
console.log(JSON.stringify({ page: path || '/', scheme, violations }));
|
|
}
|
|
await context.close();
|
|
}
|
|
await browser.close();
|