feat: Leistungsseiten intern für SEO vernetzen

This commit is contained in:
Leon Tonhäuser committed 2026-07-30 12:38:17 +02:00
1 parent 19dce0665f
commit a235112f4b
11 files changed
+97 -12

No files matched your search

+67 -1
View File
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { readFileSync, readdirSync, writeFileSync } from 'node:fs';
import { existsSync, readFileSync, readdirSync, writeFileSync } from 'node:fs';
import path from 'node:path';
import vm from 'node:vm';
import { fileURLToPath } from 'node:url';
@@ -227,6 +227,72 @@ if (wants('event')) {
});
}
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 = urlPath === '/' ? 'index.html' : `${urlPath.slice(1)}.html`;
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));
const target = clean === '' ? 'index.html' : clean.endsWith('.html') ? clean : `${clean}.html`;
assert.ok(existsSync(path.join(PUBLIC, target)), `${file} → ${href}`);
}
}
});
}
if (failures.length) {
console.error(`\n${failures.length} Prüfung(en) fehlgeschlagen.`);
process.exit(1);