Skip to content

Commit 45b7269

Browse files
zephyrieclaude
andcommitted
chore: dev-middleware error logging, styleguide modernization, snapshot script hardening
The md-twins and llms-txt dev middlewares log conversion failures instead of failing silently. STYLEGUIDE's page-structure example and checklist now show the BaseLayout pattern instead of retired SSI includes. visual-snapshot.js validates its arguments and cleans up the server/browser on failure. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
1 parent 0e3e5e2 commit 45b7269

4 files changed

Lines changed: 45 additions & 32 deletions

File tree

docs/STYLEGUIDE.md

Lines changed: 17 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -103,25 +103,20 @@ Always use this above section titles (`text-brand-teal` on light backgrounds; `t
103103
## Layout
104104

105105
### Page Structure
106-
```html
107-
<!DOCTYPE html>
108-
<html lang="en" class="scroll-smooth">
109-
<!-- Page-specific meta tags -->
110-
<title>MONAI - Page Title</title>
111-
<meta name="description" content="...">
112-
<!-- OG tags, twitter tags, canonical -->
113-
114-
<!-- #include file="components/head.html" -->
115-
116-
<body class="flex flex-col min-h-screen bg-white">
117-
<!-- #include file="components/header.html" -->
118-
<main class="flex-grow pt-16">
119-
<!-- Page content sections here -->
120-
<!-- #include file="components/footer.html" -->
121-
</main>
122-
<!-- #include file="components/scripts.html" -->
123-
</body>
124-
</html>
106+
```astro
107+
---
108+
import BaseLayout from '../layouts/BaseLayout.astro';
109+
const frontmatter = {
110+
title: 'MONAI - Page Title',
111+
description: '...',
112+
canonical: 'https://project-monai.github.io/<name>.html',
113+
// optional: audience, schemaType, metaRefresh
114+
};
115+
---
116+
<BaseLayout {...frontmatter}>
117+
<!-- Page sections here. BaseLayout provides <head> (SEO, JSON-LD, GA4),
118+
Header, Footer, and the shared scripts. -->
119+
</BaseLayout>
125120
```
126121

127122
### Container
@@ -530,17 +525,13 @@ For displaying code snippets (e.g., install commands, code examples):
530525
When creating a new page:
531526

532527
1. Use `class="scroll-smooth"` on `<html>` (NOT inline style)
533-
2. Include all 4 component files via SSI:
534-
- `<!-- #include file="components/head.html" -->`
535-
- `<!-- #include file="components/header.html" -->`
536-
- `<!-- #include file="components/footer.html" -->`
537-
- `<!-- #include file="components/scripts.html" -->`
538-
3. Add complete meta tags: title, description, og:title, og:description, og:url, twitter:title, twitter:description, canonical
528+
2. Wrap the page in `BaseLayout` (it renders head, Header, Footer, and shared scripts).
529+
3. Fill the `frontmatter` const: title, description, canonical (BaseHead derives OG/Twitter/canonical/markdown-twin tags from it)
539530
4. Start with a light hero (`bg-gradient-to-br from-white via-brand-light/40 to-white`, dark text; see DESIGN.md, dark heroes are legacy)
540531
5. Use `reveal` classes for scroll-reveal animations, sparingly
541532
6. Alternate `bg-white` and `bg-gray-50` for content sections
542533
7. Test responsive layout at mobile (375px), tablet (768px), desktop (1280px)
543-
8. Run `npm run build` to verify SSI includes resolve
534+
8. Run `npm run build` and `npm test` to verify the page and LLM artifacts generate
544535

545536
---
546537

scripts/visual-snapshot.js

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,32 @@ const ROOT = process.argv[2];
88
const OUT = process.argv[3];
99
const PORT = 4321;
1010

11+
if (!ROOT || !OUT) {
12+
console.error('Usage: node scripts/visual-snapshot.js <ROOT> <OUT>');
13+
console.error(' ROOT: directory of built HTML to serve (e.g. ./dist)');
14+
console.error(' OUT: directory to write screenshots into');
15+
process.exit(1);
16+
}
17+
1118
(async () => {
19+
let server;
20+
let browser;
21+
try {
22+
await main();
23+
} catch (e) {
24+
console.error('visual-snapshot failed:', e.message);
25+
console.error(e.stack);
26+
process.exitCode = 1;
27+
} finally {
28+
if (browser) await browser.close().catch(() => {});
29+
if (server) server.close();
30+
}
31+
32+
async function main() {
1233
fs.mkdirSync(OUT, { recursive: true });
13-
const server = http.createServer((req, res) => handler(req, res, { public: ROOT }));
34+
server = http.createServer((req, res) => handler(req, res, { public: ROOT }));
1435
await new Promise(r => server.listen(PORT, r));
15-
const browser = await puppeteer.launch({
36+
browser = await puppeteer.launch({
1637
args: ['--no-sandbox', '--disable-setuid-sandbox'],
1738
});
1839
const page = await browser.newPage();
@@ -39,6 +60,5 @@ const PORT = 4321;
3960
console.warn(`Skip ${h}: ${e.message}`);
4061
}
4162
}
42-
await browser.close();
43-
server.close();
63+
}
4464
})();

src/integrations/llms-txt.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ export default function llmsTxt(): AstroIntegration {
6767
res.end(
6868
`<?xml version="1.0" encoding="UTF-8"?>\n<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">\n${urls}\n</urlset>\n`,
6969
);
70-
} catch {
70+
} catch (err) {
71+
console.error(`[llms-txt] dev synthesis failed for ${url}:`, err);
7172
next();
7273
}
7374
});

src/integrations/md-twins.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,8 @@ export default function mdTwins(): AstroIntegration {
128128
const md = htmlToMarkdownTwin(html, frontmatterFromHtml(html, rel));
129129
res.setHeader('Content-Type', 'text/markdown; charset=utf-8');
130130
res.end(md);
131-
} catch {
131+
} catch (err) {
132+
console.error(`[md-twins] dev twin conversion failed for ${url}:`, err);
132133
next();
133134
}
134135
});

0 commit comments

Comments
 (0)