fix: vollständige SEO-Bake-Prüfung sichern
This commit is contained in:
1 parent
6dbf5c2fec
commit
5eed960772
2 files changed
+38
-6
No files matched your search
@@ -109,6 +109,7 @@ function buildBlock(p) {
|
||||
}
|
||||
|
||||
let n = 0;
|
||||
let skipped = 0;
|
||||
for (const f of readdirSync(PUB).filter((x) => x.endsWith('.html'))) {
|
||||
const fp = path.join(PUB, f);
|
||||
const p = f === 'index.html' ? '/' : '/' + f.replace(/\.html$/, '');
|
||||
@@ -117,6 +118,7 @@ for (const f of readdirSync(PUB).filter((x) => x.endsWith('.html'))) {
|
||||
if (page.title) {
|
||||
if (!/<title>[\s\S]*?<\/title>/i.test(html)) {
|
||||
console.warn('kein <title> in', f);
|
||||
skipped++;
|
||||
continue;
|
||||
}
|
||||
html = html.replace(
|
||||
@@ -134,9 +136,13 @@ for (const f of readdirSync(PUB).filter((x) => x.endsWith('.html'))) {
|
||||
}
|
||||
const re = new RegExp('[\\t ]*' + reEsc(BEGIN) + '[\\s\\S]*?' + reEsc(END) + '\\n?');
|
||||
html = html.replace(re, '');
|
||||
if (!html.includes('</head>')) { console.warn('kein </head> in', f); continue; }
|
||||
if (!html.includes('</head>')) { console.warn('kein </head> in', f); skipped++; continue; }
|
||||
html = html.replace('</head>', buildBlock(p) + '\n</head>');
|
||||
writeFileSync(fp, html);
|
||||
n++;
|
||||
}
|
||||
console.log(`Gebacken: ${n} Seiten`);
|
||||
if (skipped) {
|
||||
console.error(`${skipped} Seite(n) übersprungen.`);
|
||||
process.exitCode = 1;
|
||||
}
|
||||
Reference in new issue
Block a user