diff --git a/prerender.cjs b/prerender.cjs
index 30350cb..9c1541d 100644
--- a/prerender.cjs
+++ b/prerender.cjs
@@ -125,6 +125,7 @@ const {
const {
generateProductMetaTags,
generateProductJsonLd,
+ generateCategoryMetaTags,
generateCategoryJsonLd,
generateHomepageMetaTags,
generateHomepageJsonLd,
@@ -621,19 +622,25 @@ const renderApp = async (categoryData, socket) => {
const filename = `Kategorie/${category.seoName}`;
const location = `/Kategorie/${category.seoName}`;
const description = `Category "${category.name}" (ID: ${category.id})`;
+ const categoryMetaTags = generateCategoryMetaTags(
+ category,
+ shopConfig.baseUrl,
+ shopConfig
+ );
const categoryJsonLd = generateCategoryJsonLd(
category,
productData?.products || [],
shopConfig.baseUrl,
shopConfig
);
+ const combinedCategoryHead = categoryMetaTags + "\n" + categoryJsonLd;
const success = render(
categoryComponent,
location,
filename,
description,
- categoryJsonLd,
+ combinedCategoryHead,
true
);
if (success) {
diff --git a/prerender/seo/category.cjs b/prerender/seo/category.cjs
index edd5f0b..492e1f2 100644
--- a/prerender/seo/category.cjs
+++ b/prerender/seo/category.cjs
@@ -1,3 +1,43 @@
+/** Safe for double-quoted HTML attributes */
+const escAttr = (str) =>
+ String(str ?? "")
+ .replace(/&/g, "&")
+ .replace(/"/g, """)
+ .replace(/ {
+ const root = baseUrl.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
+ const categoryUrl = `${root}/Kategorie/${category.seoName}`;
+ const name = category.name || `Kategorie ${category.seoName}`;
+ const site = config.siteName || config.brandName;
+ const desc = `${name} bei ${config.brandName}: Growshop-Sortiment online kaufen. Schnelle Lieferung, Laden Dresden.`;
+ const descShort = desc.length > 160 ? `${desc.slice(0, 157)}...` : desc;
+ const e = escAttr;
+ const logoUrl =
+ config.images && config.images.logo
+ ? `${root}${config.images.logo}`
+ : `${root}/assets/images/nopicture.jpg`;
+
+ return `
+
+
+
+
+
+
+
+
+
+
+
+
+ `;
+};
+
const generateCategoryJsonLd = (category, products = [], baseUrl, config) => {
// Category IDs to skip (seeds, plants, headshop items)
const skipCategoryIds = [689, 706, 709, 711, 714, 748, 749, 896, 710, 924, 923, 922, 921, 916, 278, 259, 258];
@@ -173,5 +213,6 @@ const generateCategoryJsonLd = (category, products = [], baseUrl, config) => {
};
module.exports = {
+ generateCategoryMetaTags,
generateCategoryJsonLd,
-};
\ No newline at end of file
+};
\ No newline at end of file
diff --git a/prerender/seo/index.cjs b/prerender/seo/index.cjs
index f660412..003e9da 100644
--- a/prerender/seo/index.cjs
+++ b/prerender/seo/index.cjs
@@ -5,6 +5,7 @@ const {
} = require('./product.cjs');
const {
+ generateCategoryMetaTags,
generateCategoryJsonLd,
} = require('./category.cjs');
@@ -41,6 +42,7 @@ module.exports = {
generateProductJsonLd,
// Category functions
+ generateCategoryMetaTags,
generateCategoryJsonLd,
// Homepage functions