diff --git a/prerender/seo/feeds.cjs b/prerender/seo/feeds.cjs index 78aa4ce..b11568c 100644 --- a/prerender/seo/feeds.cjs +++ b/prerender/seo/feeds.cjs @@ -386,6 +386,18 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => { return; } + // Check if product has weight data - validate BEFORE building XML + if (!product.weight || isNaN(product.weight)) { + // Track products without weight + productsNeedingWeight.push({ + id: product.articleNumber || product.seoName, + name: product.name || 'Unnamed', + url: `/Artikel/${product.seoName}` + }); + skippedCount++; + return; + } + // Check if description is missing or too short (less than 20 characters) - skip if insufficient const originalDescription = product.description ? cleanTextContent(product.description) : ''; if (!originalDescription || originalDescription.length < 20) { @@ -460,7 +472,7 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => { const googleCategory = getGoogleProductCategory(categoryId); const escapedGoogleCategory = escapeXml(googleCategory); - // Build item XML with proper formatting + // Build item XML with proper formatting (all validation passed, safe to write XML) productsXml += ` ${productId} @@ -486,21 +498,11 @@ const generateProductsXml = (allProductsData = [], baseUrl, config) => { ${gtin}`; } - // Check if product has weight data - skip if missing - if (!product.weight || isNaN(product.weight)) { - // Track products without weight - productsNeedingWeight.push({ - id: product.articleNumber || product.seoName, - name: product.name || 'Unnamed', - url: `/Artikel/${product.seoName}` - }); - skippedCount++; - return; - } - - // Add weight (we know it exists at this point) + // Add weight (we know it exists at this point since we validated it earlier) + // Convert from kg to grams (multiply by 1000) + const weightInGrams = parseFloat(product.weight) * 1000; productsXml += ` - ${parseFloat(product.weight).toFixed(2)} g`; + ${weightInGrams.toFixed(2)} g`; // Add unit pricing data (required by German law for many products) const unitPricingData = determineUnitPricingData(product); diff --git a/src/components/MainPageLayout.js b/src/components/MainPageLayout.js index 8fdfe62..4dbb6b6 100644 --- a/src/components/MainPageLayout.js +++ b/src/components/MainPageLayout.js @@ -78,9 +78,9 @@ const MainPageLayout = () => { }; const allTitles = { - home: t('titles.home'), - aktionen: t('titles.aktionen'), - filiale: t('titles.filiale') + home: t('titles.filiale'), + aktionen: t('titles.home'), + filiale: t('titles.aktionen') }; // Define all content boxes for layered rendering