Claude improvements

This commit is contained in:
Andras Schmelczer 2026-05-11 07:48:33 +01:00
parent a86940da30
commit df2267a968
79 changed files with 2695 additions and 1162 deletions

View file

@ -1,19 +1,10 @@
import { createServer } from 'node:http';
import { readFile, stat } from 'node:fs/promises';
import { readdir, readFile, stat } from 'node:fs/promises';
import path from 'node:path';
import { chromium } from 'playwright';
const dist = path.resolve('dist');
const routes = [
'/',
'/articles/',
'/articles/greatai-ai-deployment-api/',
'/writing/',
'/writing/greatai-ai-deployment-api/',
'/projects/',
'/about/',
];
const widths = [320, 390, 430];
const widths = [320, 390, 430, 768, 1024, 1440, 1920];
function contentType(file) {
if (file.endsWith('.html')) return 'text/html; charset=utf-8';
@ -27,6 +18,38 @@ function contentType(file) {
return 'application/octet-stream';
}
async function walk(dir) {
const entries = await readdir(dir, { withFileTypes: true });
const files = [];
for (const entry of entries) {
const fullPath = path.join(dir, entry.name);
if (entry.isDirectory()) {
files.push(...(await walk(fullPath)));
} else {
files.push(fullPath);
}
}
return files;
}
async function discoverRoutes() {
const files = await walk(dist);
const routes = new Set();
for (const file of files) {
if (!file.endsWith('.html')) continue;
const rel = path.relative(dist, file).replaceAll(path.sep, '/');
if (rel === '404.html') continue;
if (rel.endsWith('/index.html')) {
routes.add('/' + rel.slice(0, -'index.html'.length));
} else if (rel === 'index.html') {
routes.add('/');
} else {
routes.add('/' + rel.replace(/\.html$/, '/'));
}
}
return [...routes].sort();
}
async function resolveFile(url) {
const parsed = new URL(url, 'http://localhost');
const safePath = path
@ -52,6 +75,8 @@ async function resolveFile(url) {
return path.join(dist, '404.html');
}
const routes = await discoverRoutes();
const server = createServer(async (req, res) => {
try {
const file = await resolveFile(req.url ?? '/');
@ -122,4 +147,6 @@ if (failures.length > 0) {
process.exit(1);
}
console.log('No horizontal overflow detected at 320px, 390px, or 430px.');
console.log(
`No horizontal overflow detected at ${widths.join(', ')}px across ${routes.length} routes.`
);