feat(SEO): add price validity date to category JSON-LD
- Introduced a priceValidUntil field in the category JSON-LD to indicate the validity period of product prices, set to three months from the current date. - This enhancement improves the structured data for SEO, providing clearer information about pricing timelines.
This commit is contained in:
@@ -1,6 +1,11 @@
|
|||||||
const generateCategoryJsonLd = (category, products = [], baseUrl, config) => {
|
const generateCategoryJsonLd = (category, products = [], baseUrl, config) => {
|
||||||
const categoryUrl = `${baseUrl}/Kategorie/${category.seoName}`;
|
const categoryUrl = `${baseUrl}/Kategorie/${category.seoName}`;
|
||||||
|
|
||||||
|
// Calculate price valid date (current date + 3 months)
|
||||||
|
const priceValidDate = new Date();
|
||||||
|
priceValidDate.setMonth(priceValidDate.getMonth() + 3);
|
||||||
|
const priceValidUntil = priceValidDate.toISOString().split("T")[0];
|
||||||
|
|
||||||
const jsonLd = {
|
const jsonLd = {
|
||||||
"@context": "https://schema.org/",
|
"@context": "https://schema.org/",
|
||||||
"@type": "CollectionPage",
|
"@type": "CollectionPage",
|
||||||
@@ -57,6 +62,7 @@ const generateCategoryJsonLd = (category, products = [], baseUrl, config) => {
|
|||||||
url: `${baseUrl}/Artikel/${product.seoName}`,
|
url: `${baseUrl}/Artikel/${product.seoName}`,
|
||||||
price: product.price && !isNaN(product.price) ? product.price.toString() : "0.00",
|
price: product.price && !isNaN(product.price) ? product.price.toString() : "0.00",
|
||||||
priceCurrency: config.currency,
|
priceCurrency: config.currency,
|
||||||
|
priceValidUntil: priceValidUntil,
|
||||||
availability: product.available
|
availability: product.available
|
||||||
? "https://schema.org/InStock"
|
? "https://schema.org/InStock"
|
||||||
: "https://schema.org/OutOfStock",
|
: "https://schema.org/OutOfStock",
|
||||||
|
|||||||
Reference in New Issue
Block a user