fix: SEO-Bake idempotent halten
This commit is contained in:
1 parent
1131ca5f81
commit
6dbf5c2fec
2 files changed
+15
-1
No files matched your search
@@ -132,7 +132,7 @@ for (const f of readdirSync(PUB).filter((x) => x.endsWith('.html'))) {
|
|||||||
html = html.replace('</title>', `</title>\n\t${descriptionTag}`);
|
html = html.replace('</title>', `</title>\n\t${descriptionTag}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const re = new RegExp(reEsc(BEGIN) + '[\\s\\S]*?' + reEsc(END) + '\\n?');
|
const re = new RegExp('[\\t ]*' + reEsc(BEGIN) + '[\\s\\S]*?' + reEsc(END) + '\\n?');
|
||||||
html = html.replace(re, '');
|
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); continue; }
|
||||||
html = html.replace('</head>', buildBlock(p) + '\n</head>');
|
html = html.replace('</head>', buildBlock(p) + '\n</head>');
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import assert from 'node:assert/strict';
|
import assert from 'node:assert/strict';
|
||||||
|
import { execFileSync } from 'node:child_process';
|
||||||
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
import { existsSync, readFileSync, readdirSync } from 'node:fs';
|
||||||
import path from 'node:path';
|
import path from 'node:path';
|
||||||
import vm from 'node:vm';
|
import vm from 'node:vm';
|
||||||
@@ -43,6 +44,13 @@ function check(name, fn) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function bakeSeo() {
|
||||||
|
execFileSync(process.execPath, ['scripts/bake-seo.mjs'], {
|
||||||
|
cwd: ROOT,
|
||||||
|
stdio: 'pipe'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if (wants('core')) {
|
if (wants('core')) {
|
||||||
const config = loadConfig();
|
const config = loadConfig();
|
||||||
const cities = ['Hamburg', 'Hannover', 'Wolfsburg', 'Uelzen', 'Celle', 'Lüneburg'];
|
const cities = ['Hamburg', 'Hannover', 'Wolfsburg', 'Uelzen', 'Celle', 'Lüneburg'];
|
||||||
@@ -87,6 +95,12 @@ if (wants('core')) {
|
|||||||
assert.ok(html.includes('"serviceType":"Eventfotografie"'));
|
assert.ok(html.includes('"serviceType":"Eventfotografie"'));
|
||||||
assert.ok(html.includes('"@type":"Country","name":"Deutschland"'));
|
assert.ok(html.includes('"@type":"Country","name":"Deutschland"'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
check('erneutes SEO-Backen verändert den Event-Head nicht', () => {
|
||||||
|
const before = read('public/eventfotografie.html');
|
||||||
|
bakeSeo();
|
||||||
|
assert.equal(read('public/eventfotografie.html'), before);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (failures.length) {
|
if (failures.length) {
|
||||||
|
|||||||
Reference in new issue
Block a user