feat: add Hersteller page with manufacturer data fetching and SEO support

This commit is contained in:
sebseb7
2026-04-21 16:04:11 +02:00
parent 2c0b7aa84d
commit 66a1efd87b
10 changed files with 690 additions and 35 deletions

View File

@@ -18,7 +18,8 @@ const renderPage = (
needsRouter = false,
config,
suppressLogs = false,
productData = null
productData = null,
manufacturerData = null
) => {
const {
isProduction,
@@ -171,22 +172,44 @@ const renderPage = (
</script>
`;
// @note Create script to populate window.productCache with ONLY the static category tree
// @note Create script to populate window.productCache with static category tree and herstellerImages
let productCacheScript = '';
if (typeof global !== "undefined" && global.window && global.window.categoryCache) {
// Only include the static categoryTree_209, not any dynamic data that gets added during rendering
const staticCache = {};
if (global.window.categoryCache["209_de"]) {
staticCache["209_de"] = global.window.categoryCache["209_de"];
const hasCategoryCache = typeof global !== "undefined" && global.window && global.window.categoryCache;
const hasManufacturerData = manufacturerData && manufacturerData.length > 0;
console.log(" 📦 [" + filename + "] manufacturerData =", manufacturerData ? (manufacturerData.length + " items") : "null");
if (hasCategoryCache || hasManufacturerData) {
const cacheData = {};
// Add static categoryTree_209
if (hasCategoryCache && global.window.categoryCache["209_de"]) {
cacheData["209_de"] = global.window.categoryCache["209_de"];
}
const staticCacheData = JSON.stringify(staticCache);
productCacheScript = `
<script>
// Populate window.categoryCache with static category tree only
window.categoryCache = ${staticCacheData};
</script>
`;
// Add herstellerImages
if (hasManufacturerData) {
cacheData.herstellerImages = manufacturerData;
}
const cacheDataJson = JSON.stringify(cacheData);
let extraScripts = '';
if (hasCategoryCache && cacheData["209_de"]) {
const categoryCacheJson = JSON.stringify({ "209_de": cacheData["209_de"] });
extraScripts += 'window.categoryCache = ' + categoryCacheJson + ';';
}
if (hasManufacturerData) {
const herstellerJson = JSON.stringify(manufacturerData);
extraScripts += 'window.herstellerImages = ' + herstellerJson + ';';
}
productCacheScript = '<script>' +
'if (!window.productCache) { window.productCache = {}; }' +
'Object.assign(window.productCache, ' + cacheDataJson + ');' +
extraScripts +
'</script>';
}
// Create script to populate window.productDetailCache for individual product pages