Enhance product rendering by incorporating category information into JSON-LD generation and parallel rendering functions, improving SEO structure and breadcrumb support.

This commit is contained in:
seb
2025-07-03 07:00:13 +02:00
parent 5d5c09abbf
commit 569f053757
2 changed files with 46 additions and 6 deletions

View File

@@ -50,7 +50,7 @@ const generateProductMetaTags = (product, baseUrl, config) => {
`;
};
const generateProductJsonLd = (product, baseUrl, config) => {
const generateProductJsonLd = (product, baseUrl, config, categoryInfo = null) => {
const productUrl = `${baseUrl}/Artikel/${product.seoName}`;
const imageUrl =
product.pictureList && product.pictureList.trim()
@@ -97,6 +97,33 @@ const generateProductJsonLd = (product, baseUrl, config) => {
},
};
// Add breadcrumb if category information is available
if (categoryInfo && categoryInfo.name && categoryInfo.seoName) {
jsonLd.breadcrumb = {
"@type": "BreadcrumbList",
itemListElement: [
{
"@type": "ListItem",
position: 1,
name: "Home",
item: baseUrl,
},
{
"@type": "ListItem",
position: 2,
name: categoryInfo.name,
item: `${baseUrl}/Kategorie/${categoryInfo.seoName}`,
},
{
"@type": "ListItem",
position: 3,
name: product.name,
item: productUrl,
},
],
};
}
return `<script type="application/ld+json">${JSON.stringify(
jsonLd
)}</script>`;