Intro „Fokus": - zwei Bild-Ebenen blenden ineinander über statt hartem Bildwechsel - Unschärfe über winzige Vorschaubilder statt live berechnetem Weichzeichner (animiert werden nur noch transform und opacity) - eigene WebP-Dateien für Laptop (quer) und Handy (hoch) in assets/intro, erzeugt mit scripts/intro-bilder.py; 1,8 MB bzw. 1,1 MB statt 5,9 MB - Bühnenhöhe auf dem Handy unabhängig von der Adressleiste, größere HUD-Schrift - „Überspringen"-Knopf, Scroll-Hinweis blendet jetzt wirklich aus - Bildpfade relativ zum Skript, damit das Intro auch unter /en/ lädt Zweisprachigkeit: - englische Seiten unter public/en/, Sprachschalter in Topbar und Dock - hreflang-Verweise, SEO-Konfiguration, Sitemap und SEO-Prüfskript angepasst - docs/zweisprachigkeit.md Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
531 lines
20 KiB
JavaScript
531 lines
20 KiB
JavaScript
import assert from 'node:assert/strict';
|
||
import { execFileSync } from 'node:child_process';
|
||
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
|
||
import path from 'node:path';
|
||
import vm from 'node:vm';
|
||
import { fileURLToPath } from 'node:url';
|
||
|
||
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
|
||
const PUBLIC = path.join(ROOT, 'public');
|
||
const requested = new Set(process.argv.slice(2));
|
||
const wants = (suite) => requested.size === 0 || requested.has('all') || requested.has(suite);
|
||
const failures = [];
|
||
|
||
function read(relativePath) {
|
||
return readFileSync(path.join(ROOT, relativePath), 'utf8');
|
||
}
|
||
|
||
function visibleText(html) {
|
||
return html
|
||
.replace(/<head\b[\s\S]*?<\/head>/gi, ' ')
|
||
.replace(/<script[\s\S]*?<\/script>/gi, ' ')
|
||
.replace(/<style[\s\S]*?<\/style>/gi, ' ')
|
||
.replace(/<noscript[\s\S]*?<\/noscript>/gi, ' ')
|
||
.replace(/<[^>]+>/g, ' ')
|
||
.replace(/&[a-z0-9#]+;/gi, ' ')
|
||
.replace(/\s+/g, ' ')
|
||
.trim();
|
||
}
|
||
|
||
function visibleMainText(html) {
|
||
const main = html.match(/<main\b[\s\S]*?<\/main>/i);
|
||
return main ? visibleText(main[0]) : '';
|
||
}
|
||
|
||
function visibleWordCount(html) {
|
||
const text = visibleMainText(html);
|
||
return text ? text.split(' ').length : 0;
|
||
}
|
||
|
||
function pageHtml(file) {
|
||
return read(`public/${file}`);
|
||
}
|
||
|
||
// PAGES-Pfad → Datei unter public/ ('/' und '/en' sind Verzeichnis-Startseiten)
|
||
function pageFile(urlPath) {
|
||
if (urlPath === '/') return 'index.html';
|
||
if (urlPath === '/en') return 'en/index.html';
|
||
return `${urlPath.slice(1)}.html`;
|
||
}
|
||
|
||
function loadConfig() {
|
||
const context = { window: {} };
|
||
vm.createContext(context);
|
||
vm.runInContext(read('public/custom/seo-config.js'), context);
|
||
return context.window.SEO_CONFIG;
|
||
}
|
||
|
||
function count(text, pattern) {
|
||
return (text.match(pattern) || []).length;
|
||
}
|
||
|
||
function htmlEscape(value) {
|
||
return String(value)
|
||
.replace(/&/g, '&')
|
||
.replace(/"/g, '"')
|
||
.replace(/</g, '<')
|
||
.replace(/>/g, '>');
|
||
}
|
||
|
||
function check(name, fn) {
|
||
try {
|
||
fn();
|
||
console.log(`PASS ${name}`);
|
||
} catch (error) {
|
||
failures.push(`${name}: ${error.message}`);
|
||
console.error(`FAIL ${name}: ${error.message}`);
|
||
}
|
||
}
|
||
|
||
function bakeSeo() {
|
||
return execFileSync(process.execPath, ['scripts/bake-seo.mjs'], {
|
||
cwd: ROOT,
|
||
encoding: 'utf8',
|
||
stdio: 'pipe'
|
||
});
|
||
}
|
||
|
||
function snapshotTopLevelHtml() {
|
||
return readdirSync(PUBLIC)
|
||
.filter((name) => name.endsWith('.html'))
|
||
.sort()
|
||
.map((name) => [name, readFileSync(path.join(PUBLIC, name), 'utf8')]);
|
||
}
|
||
|
||
if (wants('core')) {
|
||
const config = loadConfig();
|
||
const cities = ['Hamburg', 'Hannover', 'Wolfsburg', 'Uelzen', 'Celle', 'Lüneburg'];
|
||
|
||
check('Geschäftsort ist Ebstorf', () => {
|
||
assert.equal(config.BUSINESS.addressLocality, 'Ebstorf');
|
||
});
|
||
|
||
check('alle sechs Sportregionen sind zentral gepflegt', () => {
|
||
assert.deepEqual(Array.from(config.BUSINESS.areaServed), cities);
|
||
});
|
||
|
||
check('sichtbare Wortzahl berücksichtigt nur main', () => {
|
||
const html = '<main>Eins zwei drei</main><footer>Vier fünf</footer>';
|
||
assert.equal(visibleWordCount(html), 3);
|
||
});
|
||
|
||
check('crawlbare Seiten behaupten keinen Standort Uelzen', () => {
|
||
for (const urlPath of Object.keys(config.PAGES)) {
|
||
const file = pageFile(urlPath);
|
||
const html = pageHtml(file);
|
||
if (/<meta\s+name=["']robots["'][^>]*\bnoindex\b/i.test(html)) continue;
|
||
assert.doesNotMatch(
|
||
html,
|
||
/(?:Leon Tonhäuser|Sportfotograf(?:ie)?(?: von Leon Tonhäuser)?) aus Uelzen/i,
|
||
file
|
||
);
|
||
}
|
||
});
|
||
|
||
check('Sportseite hat seitenspezifische Service-Daten', () => {
|
||
const page = config.PAGES['/sportfotografie'];
|
||
assert.equal(page.service.serviceType, 'Sportfotografie');
|
||
assert.deepEqual(
|
||
Array.from(page.service.areaServed, (place) => place.name),
|
||
cities
|
||
);
|
||
assert.ok(page.jsonld.includes('service'));
|
||
});
|
||
|
||
check('Eventseite hat Hamburg und Deutschland als Einsatzgebiet', () => {
|
||
const page = config.PAGES['/eventfotografie'];
|
||
assert.deepEqual(
|
||
JSON.parse(JSON.stringify(page.service.areaServed)),
|
||
[
|
||
{ type: 'City', name: 'Hamburg' },
|
||
{ type: 'Country', name: 'Deutschland' }
|
||
]
|
||
);
|
||
assert.ok(page.jsonld.includes('service'));
|
||
});
|
||
|
||
check('gebackener Event-Head entspricht der Konfiguration', () => {
|
||
const page = config.PAGES['/eventfotografie'];
|
||
const html = read('public/eventfotografie.html');
|
||
assert.equal(count(html, /<title>/g), 1);
|
||
assert.equal(count(html, /<meta name="description"/g), 1);
|
||
assert.ok(html.includes(`<title>${htmlEscape(page.title)}</title>`));
|
||
assert.ok(html.includes(`content="${htmlEscape(page.desc)}"`));
|
||
assert.ok(html.includes('"serviceType":"Eventfotografie"'));
|
||
assert.ok(html.includes('"@type":"Country","name":"Deutschland"'));
|
||
});
|
||
|
||
check('erneutes SEO-Backen verändert keine Top-Level-HTML-Seite', () => {
|
||
const before = snapshotTopLevelHtml();
|
||
bakeSeo();
|
||
assert.deepEqual(snapshotTopLevelHtml(), before);
|
||
});
|
||
|
||
check('SEO-Bake meldet übersprungene HTML-Seiten als Fehler', () => {
|
||
const file = path.join(PUBLIC, 'impressum.html');
|
||
const original = readFileSync(file, 'utf8');
|
||
let failure;
|
||
try {
|
||
writeFileSync(file, original.replace('</head>', ''));
|
||
try {
|
||
bakeSeo();
|
||
} catch (error) {
|
||
failure = error;
|
||
}
|
||
} finally {
|
||
writeFileSync(file, original);
|
||
}
|
||
assert.ok(failure, 'das Backen muss bei übersprungenen HTML-Seiten fehlschlagen');
|
||
assert.match(String(failure.stderr), /kein <\/head> in impressum\.html/);
|
||
});
|
||
}
|
||
|
||
if (wants('sport')) {
|
||
check('Sportseite hat eindeutigen H1 und Canonical', () => {
|
||
const html = pageHtml('sportfotografie.html');
|
||
assert.equal(count(html, /<h1\b/g), 1);
|
||
assert.ok(html.includes('<h1 class="hero-title">Sportfotograf für Hamburg und Norddeutschland</h1>'));
|
||
assert.ok(html.includes('<link rel="canonical" href="https://leon-tonhaeuser.de/sportfotografie">'));
|
||
});
|
||
|
||
check('Sportseite besitzt substanziellen Inhalt', () => {
|
||
const words = visibleWordCount(pageHtml('sportfotografie.html'));
|
||
assert.ok(words >= 500 && words <= 800, `Wortzahl ${words} liegt außerhalb 500–800`);
|
||
});
|
||
|
||
check('Sportseite belegt Regionen mit vorhandenen Referenzen', () => {
|
||
const html = pageHtml('sportfotografie.html');
|
||
const visible = visibleMainText(html);
|
||
assert.ok(visible, 'sichtbarer <main>-Inhalt fehlt');
|
||
for (const href of [
|
||
'./portfolio-hamburger-sv',
|
||
'./portfolio-fc-st-pauli',
|
||
'./portfolio-hannover-96',
|
||
'./portfolio-svg-lueneburg',
|
||
'./portfolio-nfv-pokalfinale-2026'
|
||
]) {
|
||
assert.ok(html.includes(`href="${href}"`), `${href} fehlt`);
|
||
}
|
||
for (const city of ['Hamburg', 'Hannover', 'Wolfsburg', 'Uelzen', 'Celle', 'Lüneburg']) {
|
||
assert.ok(visible.includes(city), `${city} fehlt im sichtbaren main-Inhalt`);
|
||
}
|
||
});
|
||
|
||
check('Sportseite hat Service-Schema und Kontakt-CTA', () => {
|
||
const html = pageHtml('sportfotografie.html');
|
||
assert.ok(html.includes('"serviceType":"Sportfotografie"'));
|
||
assert.ok(html.includes('href="./kontakt"'));
|
||
});
|
||
}
|
||
|
||
if (wants('event')) {
|
||
check('Event-Nutzen und Referenzen können nicht nur in Metadaten stehen', () => {
|
||
const metadataOnly = pageHtml('eventfotografie.html')
|
||
.replace(/<main\b[\s\S]*?<\/main>/i, '<main>Ohne die geforderten Begriffe.</main>');
|
||
const visible = visibleText(metadataOnly);
|
||
for (const term of ['Hamburg', 'deutschlandweit', 'PR', 'Social Media', 'YES!CON 2026', 'OMR x yes!wecancer']) {
|
||
assert.ok(!visible.includes(term), `${term} darf nicht aus Metadaten als sichtbarer Inhalt gelten`);
|
||
}
|
||
});
|
||
|
||
check('Eventseite hat eindeutigen H1 und substanziellen Inhalt', () => {
|
||
const html = pageHtml('eventfotografie.html');
|
||
assert.equal(count(html, /<h1\b/g), 1);
|
||
assert.ok(html.includes('<h1 class="hero-title">Eventfotograf für Hamburg und deutschlandweite Veranstaltungen</h1>'));
|
||
const words = visibleWordCount(html);
|
||
assert.ok(words >= 500 && words <= 800, `Wortzahl ${words} liegt außerhalb 500–800`);
|
||
});
|
||
|
||
check('Eventseite nennt Nutzen, Referenzen und Deutschland', () => {
|
||
const html = pageHtml('eventfotografie.html');
|
||
const visible = visibleText(html);
|
||
for (const term of ['Hamburg', 'deutschlandweit', 'PR', 'Social Media', 'YES!CON 2026', 'OMR x yes!wecancer']) {
|
||
assert.ok(visible.includes(term), `${term} fehlt im sichtbaren Inhalt`);
|
||
}
|
||
assert.ok(html.includes('"serviceType":"Eventfotografie"'));
|
||
assert.ok(html.includes('"@type":"Country","name":"Deutschland"'));
|
||
});
|
||
|
||
check('Startseite verlinkt beide Leistungsseiten', () => {
|
||
const html = pageHtml('index.html');
|
||
assert.ok(html.includes('href="./sportfotografie"'));
|
||
assert.ok(html.includes('href="./eventfotografie"'));
|
||
});
|
||
|
||
check('Leistungs-Hub verlinkt beide Leistungsseiten', () => {
|
||
const html = pageHtml('leistungen.html');
|
||
assert.ok(html.includes('href="./sportfotografie"'));
|
||
assert.ok(html.includes('href="./eventfotografie"'));
|
||
});
|
||
}
|
||
|
||
if (wants('links')) {
|
||
const sportPages = [
|
||
'portfolio-hamburger-sv.html',
|
||
'portfolio-fc-st-pauli.html',
|
||
'portfolio-hannover-96.html',
|
||
'portfolio-svg-lueneburg.html',
|
||
'portfolio-nfv-pokalfinale-2026.html'
|
||
];
|
||
const eventPages = [
|
||
'portfolio-yes-con-2026.html',
|
||
'portfolio-omr-yes-wecancer.html',
|
||
'portfolio-abiball.html'
|
||
];
|
||
|
||
check('Sportreferenzen verlinken die Sportseite', () => {
|
||
for (const file of sportPages) {
|
||
assert.ok(pageHtml(file).includes('href="./sportfotografie"'), `${file} fehlt`);
|
||
}
|
||
});
|
||
|
||
check('Eventreferenzen verlinken die Eventseite', () => {
|
||
for (const file of eventPages) {
|
||
assert.ok(pageHtml(file).includes('href="./eventfotografie"'), `${file} fehlt`);
|
||
}
|
||
});
|
||
|
||
check('Sitemap enthält die Sportseite und aktuelle Hub-Daten', () => {
|
||
const xml = read('public/sitemap.xml');
|
||
assert.equal(count(xml, /<loc>https:\/\/leon-tonhaeuser\.de\/sportfotografie<\/loc>/g), 1);
|
||
for (const url of ['/', '/leistungen', '/eventfotografie', '/sportfotografie']) {
|
||
const escaped = url === '/' ? '\\/' : url.replace(/\//g, '\\/');
|
||
const entry = new RegExp(`<loc>https:\\/\\/leon-tonhaeuser\\.de${escaped}<\\/loc><lastmod>2026-07-30<\\/lastmod>`);
|
||
assert.ok(entry.test(xml), `${url} hat kein lastmod 2026-07-30`);
|
||
}
|
||
});
|
||
|
||
check('alle konfigurierten Seiten haben genau einen statischen SEO-Block', () => {
|
||
const config = loadConfig();
|
||
for (const [urlPath, page] of Object.entries(config.PAGES)) {
|
||
const file = pageFile(urlPath);
|
||
const html = pageHtml(file);
|
||
assert.equal(count(html, /<!-- STATIC-SEO:/g), 1, `${file}: Startmarker`);
|
||
assert.equal(count(html, /<!-- \/STATIC-SEO -->/g), 1, `${file}: Endmarker`);
|
||
assert.equal(count(html, /<title>/g), 1, `${file}: Title`);
|
||
assert.equal(count(html, /<meta name="description"/g), 1, `${file}: Description`);
|
||
assert.ok(html.includes(`<title>${htmlEscape(page.title)}</title>`), `${file}: Title-Wert`);
|
||
}
|
||
});
|
||
|
||
check('alle relativen HTML-Links zeigen auf vorhandene Seiten', () => {
|
||
const files = readdirSync(PUBLIC).filter((file) => file.endsWith('.html'));
|
||
for (const file of files) {
|
||
const html = pageHtml(file);
|
||
const hrefs = Array.from(
|
||
html.matchAll(/<a\b[^>]*\shref="(\.\/[^"#?]*)/g),
|
||
(match) => match[1]
|
||
);
|
||
for (const href of hrefs) {
|
||
const clean = decodeURIComponent(href.slice(2));
|
||
// Verzeichnis-Links (z. B. ./en/ für die Sprachversion) auf index.html auflösen
|
||
const target =
|
||
clean === '' ? 'index.html'
|
||
: clean.endsWith('/') ? `${clean}index.html`
|
||
: clean.endsWith('.html') ? clean
|
||
: `${clean}.html`;
|
||
assert.ok(existsSync(path.join(PUBLIC, target)), `${file} → ${href}`);
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
if (wants('syntax')) {
|
||
check('alle ausführbaren Inline-Skripte der Top-Level-Seiten sind syntaktisch gültig', () => {
|
||
const files = readdirSync(PUBLIC).filter((file) => file.endsWith('.html')).sort();
|
||
for (const file of files) {
|
||
const html = pageHtml(file);
|
||
const scripts = Array.from(
|
||
html.matchAll(/<script\b([^>]*)>([\s\S]*?)<\/script>/gi),
|
||
(match) => ({ attributes: match[1], source: match[2] })
|
||
);
|
||
for (const [index, script] of scripts.entries()) {
|
||
if (/\bsrc\s*=/i.test(script.attributes) || /\btype\s*=\s*["']application\/ld\+json["']/i.test(script.attributes)) {
|
||
continue;
|
||
}
|
||
new vm.Script(script.source, { filename: `${file} inline script ${index + 1}` });
|
||
}
|
||
}
|
||
});
|
||
}
|
||
|
||
if (wants('responsive')) {
|
||
check('Hero-Titel können auf Mobilgeräten lange Wörter umbrechen', () => {
|
||
const css = read('public/custom/site.css');
|
||
const mobileHeroRule = css.match(
|
||
/@media\s*\(max-width:\s*809\.98px\)\s*\{\s*\.hero-title\s*\{([^}]*)\}\s*\}/
|
||
);
|
||
assert.ok(mobileHeroRule, 'Mobile .hero-title-Regel fehlt');
|
||
assert.match(mobileHeroRule[1], /hyphens:\s*auto;/);
|
||
assert.match(mobileHeroRule[1], /overflow-wrap:\s*anywhere;/);
|
||
});
|
||
}
|
||
|
||
if (wants('favicon')) {
|
||
check('alle Top-Level-Seiten deklarieren das SVG-Favicon und den ICO-Fallback', () => {
|
||
const files = readdirSync(PUBLIC).filter((file) => file.endsWith('.html')).sort();
|
||
for (const file of files) {
|
||
const html = pageHtml(file);
|
||
assert.match(
|
||
html,
|
||
/<link rel="icon" href="assets\/favicon\.svg" type="image\/svg\+xml">/,
|
||
`${file}: SVG-Favicon-Link fehlt`
|
||
);
|
||
assert.match(
|
||
html,
|
||
/<link rel="alternate icon" href="favicon\.ico" sizes="any">/,
|
||
`${file}: ICO-Fallback-Link fehlt`
|
||
);
|
||
}
|
||
});
|
||
|
||
check('Favicon-Dateien enthalten ein kontrastreiches LT-Monogramm', () => {
|
||
const svgAsset = path.join(PUBLIC, 'assets', 'favicon.svg');
|
||
const icoAsset = path.join(PUBLIC, 'favicon.ico');
|
||
assert.ok(existsSync(svgAsset), 'public/assets/favicon.svg fehlt');
|
||
assert.ok(existsSync(icoAsset), 'public/favicon.ico fehlt');
|
||
const svg = read('public/assets/favicon.svg');
|
||
assert.match(svg, /viewBox="0 0 64 64"/);
|
||
assert.match(svg, /aria-label="Leon Tonhäuser"/);
|
||
assert.match(svg, />LT<\/text>/);
|
||
});
|
||
}
|
||
|
||
if (wants('agb')) {
|
||
const expectedTitle = 'AGB & Lizenzbedingungen | Leon Tonhäuser';
|
||
const expectedDescription = 'Allgemeine Geschäftsbedingungen sowie Nutzungs- und Lizenzbedingungen von Leon Tonhäuser für Fotoaufträge, Bildlizenzen und das Redaktionsportal.';
|
||
const headings = [
|
||
'1. Anbieter und Geltungsbereich',
|
||
'2. Vertragsschluss und Kommunikation',
|
||
'3. Fotoaufträge',
|
||
'4. Redaktionsportal und Benutzerkonto',
|
||
'5. Urheberrecht und Umfang der Bildlizenz',
|
||
'6. Unzulässige Nutzungen und Bearbeitungen',
|
||
'7. Urhebervermerk und Metadaten',
|
||
'8. Rechte abgebildeter Personen und redaktioneller Kontext',
|
||
'9. Vergütung, Nutzungsnachweis und Rechnung',
|
||
'10. Mitwirkung, Archivierung und Datensicherung',
|
||
'11. Mängel und Beanstandungen',
|
||
'12. Haftung',
|
||
'13. Vertragsdauer und Beendigung des Portalzugangs',
|
||
'14. Datenschutz',
|
||
'15. Schlussbestimmungen'
|
||
];
|
||
|
||
check('Nutzungsbedingungen sind nur unter dem freigegebenen Slug vorhanden', () => {
|
||
assert.ok(existsSync(path.join(PUBLIC, 'nutzungsbedingungen.html')), 'public/nutzungsbedingungen.html fehlt');
|
||
assert.ok(!existsSync(path.join(PUBLIC, 'agb.html')), 'public/agb.html darf nicht bleiben');
|
||
const pages = loadConfig().PAGES;
|
||
const page = pages['/nutzungsbedingungen'];
|
||
assert.ok(page, 'SEO_CONFIG.PAGES[\'/nutzungsbedingungen\'] fehlt');
|
||
assert.equal(pages['/agb'], undefined, 'alte /agb-Konfiguration darf nicht bleiben');
|
||
assert.equal(page.title, expectedTitle);
|
||
assert.equal(page.desc, expectedDescription);
|
||
assert.deepEqual(Array.from(page.jsonld), ['breadcrumb']);
|
||
assert.ok(
|
||
pageHtml('nutzungsbedingungen.html').includes('"name":"AGB & Lizenzbedingungen"'),
|
||
'gebackener Breadcrumb-Name ist nicht freigegeben'
|
||
);
|
||
});
|
||
|
||
check('AGB-Seite ist semantisch in 15 Abschnitte gegliedert', () => {
|
||
const html = pageHtml('nutzungsbedingungen.html');
|
||
assert.equal(count(html, /<h1\b/g), 1, 'H1-Anzahl');
|
||
assert.equal(count(html, /<h2\b/g), 15, 'H2-Anzahl');
|
||
assert.ok(html.includes('<h1 class="hero-title">AGB & Lizenzbedingungen</h1>'));
|
||
for (const [index, heading] of headings.entries()) {
|
||
const section = index + 1;
|
||
assert.equal(count(html, new RegExp(`id="agb-${section}"`, 'g')), 1, `Abschnitt agb-${section}`);
|
||
assert.equal(count(html, new RegExp(`href="#agb-${section}"`, 'g')), 1, `Inhaltslink agb-${section}`);
|
||
assert.ok(html.includes(`<h2>${heading}</h2>`), heading);
|
||
}
|
||
});
|
||
|
||
check('AGB-Seite enthält die freigegebenen Vertragsdaten ohne interne Platzhalter', () => {
|
||
const html = pageHtml('nutzungsbedingungen.html');
|
||
const visible = visibleMainText(html);
|
||
for (const text of [
|
||
'Leon Tonhäuser | Sportfotografie',
|
||
'Tannenworthring 40, 29574 Ebstorf',
|
||
'mail@leon-tonhaeuser.de',
|
||
'Stand: 11. August 2026',
|
||
'Rechnungen sind innerhalb von 14 Kalendertagen ab Zugang ohne Abzug zahlbar',
|
||
'© Leon Tonhäuser',
|
||
'der Sitz des Fotografen ausschließlicher Gerichtsstand'
|
||
]) {
|
||
assert.ok(visible.includes(text), `${text} fehlt`);
|
||
}
|
||
assert.ok(html.includes('href="./datenschutz"'));
|
||
assert.ok(html.includes('href="./impressum"'));
|
||
assert.doesNotMatch(
|
||
html,
|
||
/\[(?:VOLLSTÄNDIGER|ANSCHRIFT|E-MAIL|UST-ID|ORT DES GERICHTSSTANDS|URL)|Arbeitsentwurf|Wichtiger Hinweis|Hinweise für die KI|Verwendete amtliche Grundlagen/i
|
||
);
|
||
});
|
||
|
||
check('AGB-Seite bietet eine druckfreundliche Ausgabe', () => {
|
||
const html = pageHtml('nutzungsbedingungen.html');
|
||
const css = read('public/custom/site.css');
|
||
assert.match(html, /<button\b[^>]*\btype="button"[^>]*\bonclick="window\.print\(\)"[^>]*>/);
|
||
const printRules = css.match(/@media\s+print\s*\{([\s\S]*?)\n\}/);
|
||
assert.ok(printRules, '@media print fehlt');
|
||
assert.match(printRules[1], /\.topbar/);
|
||
assert.match(printRules[1], /\.dock/);
|
||
assert.match(printRules[1], /\.footer/);
|
||
assert.match(printRules[1], /\.agb-drucken/);
|
||
assert.match(printRules[1], /display:\s*none/);
|
||
});
|
||
|
||
check('AGB-H1 bleibt mobil ohne Worttrennung lesbar', () => {
|
||
const html = pageHtml('nutzungsbedingungen.html');
|
||
const css = read('public/custom/site.css');
|
||
assert.match(html, /<body\s+class="agb-seite">/);
|
||
const mobileTitleRule = css.match(
|
||
/@media\s*\(max-width:\s*809\.98px\)\s*\{[\s\S]*?\.agb-seite\s+\.hero-title\s*\{([^}]*)\}/
|
||
);
|
||
assert.ok(mobileTitleRule, 'mobile AGB-H1-Regel fehlt');
|
||
assert.match(mobileTitleRule[1], /hyphens:\s*none;/);
|
||
assert.match(mobileTitleRule[1], /overflow-wrap:\s*normal;/);
|
||
});
|
||
|
||
check('jeder vorhandene Top-Level-Footer verlinkt nur den neuen Slug', () => {
|
||
const files = readdirSync(PUBLIC).filter((file) => file.endsWith('.html')).sort();
|
||
let footerCount = 0;
|
||
for (const file of files) {
|
||
const footer = pageHtml(file).match(/<footer\b[\s\S]*?<\/footer>/i);
|
||
if (!footer) continue;
|
||
footerCount += 1;
|
||
assert.equal(count(footer[0], /href="\.\/nutzungsbedingungen"/g), 1, `${file}: Nutzungsbedingungen-Link im Footer`);
|
||
assert.equal(count(footer[0], /href="\.\/agb"/g), 0, `${file}: alter AGB-Link im Footer`);
|
||
}
|
||
assert.ok(footerCount >= 28, `nur ${footerCount} Footer geprüft`);
|
||
});
|
||
|
||
check('Kontaktformular verweist unmittelbar auf die AGB', () => {
|
||
const html = pageHtml('kontakt.html');
|
||
const form = html.match(/<form\b[^>]*id="kontaktformular"[\s\S]*?<\/form>/i);
|
||
assert.ok(form, 'Kontaktformular fehlt');
|
||
assert.match(
|
||
form[0],
|
||
/<button\b[^>]*type="submit"[\s\S]*?<p\b[^>]*class="kontakt-rechtshinweis"[^>]*>Für geschäftliche Anfragen gelten unsere <a href="\.\/nutzungsbedingungen">AGB & Lizenzbedingungen<\/a>\.<\/p>/
|
||
);
|
||
});
|
||
|
||
check('Sitemap enthält nur den neuen Slug mit aktuellem Versionsdatum', () => {
|
||
const xml = read('public/sitemap.xml');
|
||
assert.equal(count(xml, /<loc>https:\/\/leon-tonhaeuser\.de\/nutzungsbedingungen<\/loc>/g), 1);
|
||
assert.doesNotMatch(xml, /<loc>https:\/\/leon-tonhaeuser\.de\/agb<\/loc>/);
|
||
assert.match(
|
||
xml,
|
||
/<loc>https:\/\/leon-tonhaeuser\.de\/nutzungsbedingungen<\/loc><lastmod>2026-08-11<\/lastmod><changefreq>yearly<\/changefreq><priority>0\.2<\/priority>/
|
||
);
|
||
});
|
||
}
|
||
|
||
if (failures.length) {
|
||
console.error(`\n${failures.length} Prüfung(en) fehlgeschlagen.`);
|
||
process.exit(1);
|
||
}
|
||
|
||
console.log('\nAlle angeforderten SEO-Prüfungen sind grün.');
|