Astro/Starlight documentation at docs/ with 21 pages: - Getting started (prerequisites, Claude Code setup, first simulation) - Tutorials (filter design, Monte Carlo yield) - Reference (all 37 tools, 5 resources, 7 prompts) - Concepts (LTspice on Linux, simulation types) Docker infrastructure with dev/prod compose overlays, Caddy reverse proxy for mcltspice.warehack.ing, and Makefile targets. Includes patch for Starlight 0.37 head schema default bug.
36 lines
1.1 KiB
JavaScript
36 lines
1.1 KiB
JavaScript
/**
|
|
* Patches @astrojs/starlight to handle undefined `data.head` in frontmatter.
|
|
*
|
|
* Starlight 0.37.x assumes docsSchema() defaults `head` to [] via Zod, but
|
|
* the content loader doesn't always apply this default, causing:
|
|
* "Cannot read properties of undefined (reading 'some')"
|
|
*
|
|
* This adds a nullish coalescing fallback: `data.head ?? []`
|
|
*/
|
|
|
|
import { readFileSync, writeFileSync } from 'node:fs';
|
|
|
|
const file = 'node_modules/@astrojs/starlight/utils/head.ts';
|
|
|
|
try {
|
|
let src = readFileSync(file, 'utf8');
|
|
const target = 'config.head, data.head)';
|
|
const replacement = 'config.head, data.head ?? [])';
|
|
|
|
if (src.includes(replacement)) {
|
|
console.log('[patch] head.ts already patched, skipping.');
|
|
process.exit(0);
|
|
}
|
|
|
|
if (!src.includes(target)) {
|
|
console.warn('[patch] Could not find target string in head.ts — Starlight may have been updated.');
|
|
process.exit(0);
|
|
}
|
|
|
|
src = src.replace(target, replacement);
|
|
writeFileSync(file, src, 'utf8');
|
|
console.log('[patch] Patched head.ts: data.head ?? []');
|
|
} catch (err) {
|
|
console.warn('[patch] Could not patch head.ts:', err.message);
|
|
}
|