From 5561685a7ae72870a1d7b2eb8a5587c40c7143cb Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:44:05 +0530 Subject: [PATCH 01/18] wip --- src/structured-data/schema.js | 44 +++++++++++++++++++++ src/structured-data/structured-data-tags.js | 10 ++--- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/src/structured-data/schema.js b/src/structured-data/schema.js index f02597ff..bfd059e1 100644 --- a/src/structured-data/schema.js +++ b/src/structured-data/schema.js @@ -151,3 +151,47 @@ export function generateAuthorPageSchema(publisherConfig, data, url) { }, }; } + +export function generateRecipePageSchema(publisherConfig, data, url, story) { + const sketchesHost = publisherConfig["sketches-host"]; + const publisherName = getTitle(publisherConfig); + const authorHREF = url["href"]; + const authorURL = `${sketchesHost}${authorHREF}`; + const authorName = get(data, ["author", "name"], ""); + // console.log("generateRecipePageSchema --->", { publisherConfig, data, url, story }); + return { + "@context": "https://schema.org/", + "@type": "Recipe", + name: story.headline, + url: story.url, + author: { + "@type": "Person", + name: story["author-name"], + }, + image: { "@type": "ImageObject", url: story.recipeUrl }, + description: story.description, + recipeIngredient: ["1 cup sugar", "2 cups flour", "1 cup chocolate chips"], + recipeInstructions: [ + { + "@type": "HowToStep", + text: "Preheat the oven to 350 degrees F.", + }, + { + "@type": "HowToStep", + text: "Mix the sugar and flour.", + }, + { + "@type": "HowToStep", + text: "Add the chocolate chips and bake for 10 minutes.", + }, + ], + recipeYield: "24 cookies", + prepTime: "PT20M", + cookTime: "PT10M", + totalTime: "PT30M", + nutrition: { + "@type": "NutritionInformation", + calories: "200 calories", + }, + }; +} diff --git a/src/structured-data/structured-data-tags.js b/src/structured-data/structured-data-tags.js index 755e046d..5a6843ee 100644 --- a/src/structured-data/structured-data-tags.js +++ b/src/structured-data/structured-data-tags.js @@ -265,11 +265,11 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC function getEmbedUrl(cards) { const playerUrlMapping = { "dailymotion-embed-script": "dailymotion-url", - "instagram": "instagram-url", + instagram: "instagram-url", "facebook-video": "facebook-url", - "tweet": "tweet-url", + tweet: "tweet-url", "vimeo-video": "vimeo-url", - "brightcove-video": "player-url" + "brightcove-video": "player-url", }; for (const card of cards) { @@ -280,7 +280,7 @@ function getEmbedUrl(cards) { if (elem.metadata && elem.metadata[playerUrlField]) { return elem.metadata[playerUrlField]; } - }; + } if (elem.type === "youtube-video" && elem.subtype === null) { if (elem.url) { return elem.url; @@ -446,9 +446,9 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re const isStructuredDataEmpty = Object.keys(structuredData).length === 0; const enableBreadcrumbList = get(structuredData, ["enableBreadcrumbList"], true); const structuredDataTags = get(structuredData, ["structuredDataTags"], []); - let articleData = {}; + // generateRecipePageSchema(publisherConfig, response.data, url, story); if (!isStructuredDataEmpty) { articleData = generateArticleData(structuredData, story, publisherConfig, timezone); structuredDataTags.map((type) => { From a06174a2c94190a015b9d7322ffa362ea4793948 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:48:02 +0530 Subject: [PATCH 02/18] chore(release): 1.46.4-recipe-schema.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 20ea850b..e9d622a6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.3", + "version": "1.46.4-recipe-schema.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.3", + "version": "1.46.4-recipe-schema.0", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index f857c660..31674315 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.3", + "version": "1.46.4-recipe-schema.0", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From 19e3e91b1fae4f171e2c75ef24ddf8215ddd7fb5 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:43:17 +0530 Subject: [PATCH 03/18] add recipe schema --- src/structured-data/schema.js | 2 +- src/structured-data/structured-data-tags.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/structured-data/schema.js b/src/structured-data/schema.js index bfd059e1..08334bb8 100644 --- a/src/structured-data/schema.js +++ b/src/structured-data/schema.js @@ -168,7 +168,7 @@ export function generateRecipePageSchema(publisherConfig, data, url, story) { "@type": "Person", name: story["author-name"], }, - image: { "@type": "ImageObject", url: story.recipeUrl }, + image: { "@type": "ImageObject", url: story.url }, description: story.description, recipeIngredient: ["1 cup sugar", "2 cups flour", "1 cup chocolate chips"], recipeInstructions: [ diff --git a/src/structured-data/structured-data-tags.js b/src/structured-data/structured-data-tags.js index 5a6843ee..9e4656ac 100644 --- a/src/structured-data/structured-data-tags.js +++ b/src/structured-data/structured-data-tags.js @@ -3,6 +3,7 @@ import { getQueryParams, stripMillisecondsFromTime } from "../utils"; import { generateTagsForEntity } from "./entity"; import { generateAuthorPageSchema, + generateRecipePageSchema, getSchemaBlogPosting, getSchemaBreadcrumbList, getSchemaContext, @@ -448,7 +449,6 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re const structuredDataTags = get(structuredData, ["structuredDataTags"], []); let articleData = {}; - // generateRecipePageSchema(publisherConfig, response.data, url, story); if (!isStructuredDataEmpty) { articleData = generateArticleData(structuredData, story, publisherConfig, timezone); structuredDataTags.map((type) => { @@ -475,6 +475,10 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re if (!isStructuredDataEmpty && pageType === "story-page") { const newsArticleTags = generateNewsArticleTags(); newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags()); + if (story["story-template"] === "recipe") { + const recipeTags = generateRecipePageSchema(publisherConfig, response.data, url, story); + tags.push(recipeTags); + } } if (!isStructuredDataEmpty && pageType === "story-page-amp") { From 12d588ce42fa889b7d9526dc486114524056ee26 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Wed, 24 Jul 2024 11:44:05 +0530 Subject: [PATCH 04/18] chore(release): 1.46.4-recipe-schema.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index e9d622a6..44373893 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.0", + "version": "1.46.4-recipe-schema.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.0", + "version": "1.46.4-recipe-schema.1", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index 31674315..251e746d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.0", + "version": "1.46.4-recipe-schema.1", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From 32bf4696c7f5f49cd2e18df884e6fce5d89184ee Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:11:37 +0530 Subject: [PATCH 05/18] add recipe tags in recipe page --- src/structured-data/structured-data-tags.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/structured-data/structured-data-tags.js b/src/structured-data/structured-data-tags.js index 9e4656ac..0471b254 100644 --- a/src/structured-data/structured-data-tags.js +++ b/src/structured-data/structured-data-tags.js @@ -476,8 +476,7 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re const newsArticleTags = generateNewsArticleTags(); newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags()); if (story["story-template"] === "recipe") { - const recipeTags = generateRecipePageSchema(publisherConfig, response.data, url, story); - tags.push(recipeTags); + tags.push(ldJson("Recipe", generateRecipePageSchema(publisherConfig, response.data, url, story))); } } From 5d6b3d56e9d423da89dcd433c96ba62aea9aade6 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Wed, 24 Jul 2024 12:12:16 +0530 Subject: [PATCH 06/18] chore(release): 1.46.4-recipe-schema.2 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 44373893..2b41a8af 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.1", + "version": "1.46.4-recipe-schema.2", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.1", + "version": "1.46.4-recipe-schema.2", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index 251e746d..d36a58d7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.1", + "version": "1.46.4-recipe-schema.2", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From 2acb335dc22bcb4328da4d39a2093fcbed6abefd Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:19:17 +0530 Subject: [PATCH 07/18] add recipe schema --- src/structured-data/schema.js | 52 +++++++-------------- src/structured-data/structured-data-tags.js | 16 ++++++- src/utils.js | 16 +++++++ 3 files changed, 48 insertions(+), 36 deletions(-) diff --git a/src/structured-data/schema.js b/src/structured-data/schema.js index 08334bb8..461eb735 100644 --- a/src/structured-data/schema.js +++ b/src/structured-data/schema.js @@ -1,6 +1,6 @@ import { get } from "lodash"; import { getTitle } from "../generate-common-seo"; -import { stripMillisecondsFromTime } from "../utils"; +import { extractTextFromHtmlString, getCardAttributes, stripMillisecondsFromTime } from "../utils"; export const getSchemaContext = { "@context": "http://schema.org" }; export function getSchemaType(type) { @@ -152,46 +152,28 @@ export function generateAuthorPageSchema(publisherConfig, data, url) { }; } -export function generateRecipePageSchema(publisherConfig, data, url, story) { - const sketchesHost = publisherConfig["sketches-host"]; - const publisherName = getTitle(publisherConfig); - const authorHREF = url["href"]; - const authorURL = `${sketchesHost}${authorHREF}`; - const authorName = get(data, ["author", "name"], ""); - // console.log("generateRecipePageSchema --->", { publisherConfig, data, url, story }); +export function generateRecipePageSchema(story) { + const { headline, url, "author-name": authorName } = story; + + const cardsWithAttributes = story.cards.filter((card) => getCardAttributes(card, "cardtype")); + const cardWithIngredients = cardsWithAttributes.filter((card) => + getCardAttributes(card, "cardtype").includes("ingredients ") + ); + const ingredientsRichText = cardWithIngredients[0]["story-elements"][0].text; + const ingredients = extractTextFromHtmlString(ingredientsRichText); + const instructions = []; + return { "@context": "https://schema.org/", "@type": "Recipe", - name: story.headline, - url: story.url, + name: headline, + url: url, author: { "@type": "Person", - name: story["author-name"], + name: authorName, }, - image: { "@type": "ImageObject", url: story.url }, description: story.description, - recipeIngredient: ["1 cup sugar", "2 cups flour", "1 cup chocolate chips"], - recipeInstructions: [ - { - "@type": "HowToStep", - text: "Preheat the oven to 350 degrees F.", - }, - { - "@type": "HowToStep", - text: "Mix the sugar and flour.", - }, - { - "@type": "HowToStep", - text: "Add the chocolate chips and bake for 10 minutes.", - }, - ], - recipeYield: "24 cookies", - prepTime: "PT20M", - cookTime: "PT10M", - totalTime: "PT30M", - nutrition: { - "@type": "NutritionInformation", - calories: "200 calories", - }, + recipeIngredient: ingredients, + recipeInstructions: instructions, }; } diff --git a/src/structured-data/structured-data-tags.js b/src/structured-data/structured-data-tags.js index 0471b254..172065c4 100644 --- a/src/structured-data/structured-data-tags.js +++ b/src/structured-data/structured-data-tags.js @@ -476,7 +476,21 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re const newsArticleTags = generateNewsArticleTags(); newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags()); if (story["story-template"] === "recipe") { - tags.push(ldJson("Recipe", generateRecipePageSchema(publisherConfig, response.data, url, story))); + const recipeTags = generateRecipePageSchema(story); + recipeTags.image = Object.assign( + { + "@type": "ImageObject", + }, + generateArticleImageData(story["hero-image-s3-key"], publisherConfig) + ); + recipeTags.video = Object.assign( + { + "@type": "VideoObject", + }, + generateVideoArticleData(structuredData, story, publisherConfig, timezone) + ); + + tags.push(ldJson("Recipe", recipeTags)); } } diff --git a/src/utils.js b/src/utils.js index bd4c1977..008823d1 100644 --- a/src/utils.js +++ b/src/utils.js @@ -8,6 +8,22 @@ export function objectToTags(object) { .map(([key, value]) => ({ [getPropertyName(key)]: key, content: value })); } +export function extractTextFromHtmlString(html) { + const regex = /

(.*?)<\/p>/g; + const textContents = []; + + let match; + while ((match = regex.exec(html)) !== null) { + textContents.push(match[1]); + } + + return textContents; +} + +export const getCardAttributes = (card, type) => { + return card.metadata.attributes[type]; +}; + function getPropertyName(key) { return key.startsWith("fb:") || key.startsWith("og:") ? "property" : "name"; } From 6403e84fb0ff61d6263c80d9a4516f9ddd7d8bdd Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Thu, 25 Jul 2024 11:27:43 +0530 Subject: [PATCH 08/18] chore(release): 1.46.4-recipe-schema.3 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 2b41a8af..8b558bef 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.2", + "version": "1.46.4-recipe-schema.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.2", + "version": "1.46.4-recipe-schema.3", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index d36a58d7..0ddb4775 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.2", + "version": "1.46.4-recipe-schema.3", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From c045ed59f462b0bb2bb8d21f3e6ff1463f026164 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:33:59 +0530 Subject: [PATCH 09/18] pr changes --- src/structured-data/schema.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/structured-data/schema.js b/src/structured-data/schema.js index 461eb735..9eaed98b 100644 --- a/src/structured-data/schema.js +++ b/src/structured-data/schema.js @@ -153,7 +153,7 @@ export function generateAuthorPageSchema(publisherConfig, data, url) { } export function generateRecipePageSchema(story) { - const { headline, url, "author-name": authorName } = story; + const { headline, url, "author-name": authorName, description } = story; const cardsWithAttributes = story.cards.filter((card) => getCardAttributes(card, "cardtype")); const cardWithIngredients = cardsWithAttributes.filter((card) => @@ -161,7 +161,6 @@ export function generateRecipePageSchema(story) { ); const ingredientsRichText = cardWithIngredients[0]["story-elements"][0].text; const ingredients = extractTextFromHtmlString(ingredientsRichText); - const instructions = []; return { "@context": "https://schema.org/", @@ -172,8 +171,7 @@ export function generateRecipePageSchema(story) { "@type": "Person", name: authorName, }, - description: story.description, + description: description, recipeIngredient: ingredients, - recipeInstructions: instructions, }; } From 81d40e1498001ccf63a5b9ab04349108673df3c9 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Thu, 25 Jul 2024 14:34:42 +0530 Subject: [PATCH 10/18] chore(release): 1.46.4-recipe-schema.4 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 8b558bef..0c28f543 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.3", + "version": "1.46.4-recipe-schema.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.3", + "version": "1.46.4-recipe-schema.4", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index 0ddb4775..72235cfa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.3", + "version": "1.46.4-recipe-schema.4", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From 6b4d8c7bbd976c8aa46d67f4fb5a4f54c99d3efd Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:51:20 +0530 Subject: [PATCH 11/18] pr changes --- src/structured-data/schema.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/structured-data/schema.js b/src/structured-data/schema.js index 9eaed98b..0a83b75b 100644 --- a/src/structured-data/schema.js +++ b/src/structured-data/schema.js @@ -159,7 +159,7 @@ export function generateRecipePageSchema(story) { const cardWithIngredients = cardsWithAttributes.filter((card) => getCardAttributes(card, "cardtype").includes("ingredients ") ); - const ingredientsRichText = cardWithIngredients[0]["story-elements"][0].text; + const ingredientsRichText = get(cardWithIngredients, ["0", "story-elements", "0", "text"], ""); const ingredients = extractTextFromHtmlString(ingredientsRichText); return { From aa2fcd63d666eed6a1fd032d8b008392b1af2089 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Wed, 31 Jul 2024 16:52:10 +0530 Subject: [PATCH 12/18] chore(release): 1.46.4-recipe-schema.5 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0c28f543..63468e3d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.4", + "version": "1.46.4-recipe-schema.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.4", + "version": "1.46.4-recipe-schema.5", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index 72235cfa..5a1474a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.4", + "version": "1.46.4-recipe-schema.5", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From 0007d21117af44bc6dd398d0f3d00b71d7cba5dd Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:57:21 +0530 Subject: [PATCH 13/18] add recipe schema for amp pages --- src/structured-data/structured-data-tags.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/structured-data/structured-data-tags.js b/src/structured-data/structured-data-tags.js index 172065c4..9e93761a 100644 --- a/src/structured-data/structured-data-tags.js +++ b/src/structured-data/structured-data-tags.js @@ -497,6 +497,23 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re if (!isStructuredDataEmpty && pageType === "story-page-amp") { const newsArticleTags = generateNewsArticleTags(); newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags()); + if (story["story-template"] === "recipe") { + const recipeTags = generateRecipePageSchema(story); + recipeTags.image = Object.assign( + { + "@type": "ImageObject", + }, + generateArticleImageData(story["hero-image-s3-key"], publisherConfig) + ); + recipeTags.video = Object.assign( + { + "@type": "VideoObject", + }, + generateVideoArticleData(structuredData, story, publisherConfig, timezone) + ); + + tags.push(ldJson("Recipe", recipeTags)); + } } if (!isStructuredDataEmpty && structuredData.header) { From 7470894daa07aa891b54a4af0271e7ecb97a6a68 Mon Sep 17 00:00:00 2001 From: phaneendra <58028287+cricket-lover@users.noreply.github.com> Date: Mon, 19 Aug 2024 16:58:18 +0530 Subject: [PATCH 14/18] chore(release): 1.46.4-recipe-schema.6 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 63468e3d..ca42381a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.5", + "version": "1.46.4-recipe-schema.6", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.5", + "version": "1.46.4-recipe-schema.6", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index 5a1474a4..842744d4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.5", + "version": "1.46.4-recipe-schema.6", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From 39214e1022752a547d1b12a9523381c5706af68e Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Mon, 4 Nov 2024 15:17:01 +0530 Subject: [PATCH 15/18] add & refactor. recipe schema --- src/structured-data/schema.js | 21 ++++++++++++--------- src/utils.js | 16 ---------------- 2 files changed, 12 insertions(+), 25 deletions(-) diff --git a/src/structured-data/schema.js b/src/structured-data/schema.js index 0a83b75b..f317e241 100644 --- a/src/structured-data/schema.js +++ b/src/structured-data/schema.js @@ -1,6 +1,6 @@ import { get } from "lodash"; import { getTitle } from "../generate-common-seo"; -import { extractTextFromHtmlString, getCardAttributes, stripMillisecondsFromTime } from "../utils"; +import { stripMillisecondsFromTime } from "../utils"; export const getSchemaContext = { "@context": "http://schema.org" }; export function getSchemaType(type) { @@ -153,14 +153,13 @@ export function generateAuthorPageSchema(publisherConfig, data, url) { } export function generateRecipePageSchema(story) { - const { headline, url, "author-name": authorName, description } = story; - - const cardsWithAttributes = story.cards.filter((card) => getCardAttributes(card, "cardtype")); - const cardWithIngredients = cardsWithAttributes.filter((card) => - getCardAttributes(card, "cardtype").includes("ingredients ") - ); - const ingredientsRichText = get(cardWithIngredients, ["0", "story-elements", "0", "text"], ""); - const ingredients = extractTextFromHtmlString(ingredientsRichText); + const { headline, url, "author-name": authorName, description, metadata } = story; + const servings = get(metadata, ["servings"], ""); + const ingredients = get(metadata, ["ingredients"], ""); + const recipeAttributes = get(metadata, ["story-attributes"], ""); + const cuisine = get(recipeAttributes, ["cuisine", "0"], ""); + const preperationtime = get(recipeAttributes, ["preparationtime", "0"], ""); + const cookingtime = get(recipeAttributes, ["cookingtime", "0"], ""); return { "@context": "https://schema.org/", @@ -173,5 +172,9 @@ export function generateRecipePageSchema(story) { }, description: description, recipeIngredient: ingredients, + prepTime: preperationtime, + cookTime: cookingtime, + recipeCuisine: cuisine, + recipeYield: servings, }; } diff --git a/src/utils.js b/src/utils.js index 008823d1..bd4c1977 100644 --- a/src/utils.js +++ b/src/utils.js @@ -8,22 +8,6 @@ export function objectToTags(object) { .map(([key, value]) => ({ [getPropertyName(key)]: key, content: value })); } -export function extractTextFromHtmlString(html) { - const regex = /

(.*?)<\/p>/g; - const textContents = []; - - let match; - while ((match = regex.exec(html)) !== null) { - textContents.push(match[1]); - } - - return textContents; -} - -export const getCardAttributes = (card, type) => { - return card.metadata.attributes[type]; -}; - function getPropertyName(key) { return key.startsWith("fb:") || key.startsWith("og:") ? "property" : "name"; } From f4e07eab47c9e59a21a66af10d1112c8df29de5c Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Mon, 4 Nov 2024 15:18:11 +0530 Subject: [PATCH 16/18] add: package-lock.json --- package-lock.json | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/package-lock.json b/package-lock.json index ca42381a..deea9ec1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12134,8 +12134,7 @@ "version": "5.3.2", "resolved": "https://registry.npmjs.org/acorn-jsx/-/acorn-jsx-5.3.2.tgz", "integrity": "sha512-rq9s+JNhf0IChjtDXxllJ7g41oZk5SlXtp0LHwyA5cejwn7vKmKp4pPri6YEePv2PU65sAsegbXtIinmDFDXgQ==", - "dev": true, - "requires": {} + "dev": true }, "add-stream": { "version": "1.0.0", @@ -13440,8 +13439,7 @@ "date-fns-tz": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/date-fns-tz/-/date-fns-tz-1.3.7.tgz", - "integrity": "sha512-1t1b8zyJo+UI8aR+g3iqr5fkUHWpd58VBx8J/ZSQ+w7YrGlw80Ag4sA86qkfCXRBLmMc4I2US+aPMd4uKvwj5g==", - "requires": {} + "integrity": "sha512-1t1b8zyJo+UI8aR+g3iqr5fkUHWpd58VBx8J/ZSQ+w7YrGlw80Ag4sA86qkfCXRBLmMc4I2US+aPMd4uKvwj5g==" }, "dateformat": { "version": "3.0.3", @@ -13934,15 +13932,13 @@ "version": "8.5.0", "resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.5.0.tgz", "integrity": "sha512-obmWKLUNCnhtQRKc+tmnYuQl0pFU1ibYJQ5BGhTVB08bHe9wC8qUeG7c08dj9XX+AuPj1YSGSQIHl1pnDHZR0Q==", - "dev": true, - "requires": {} + "dev": true }, "eslint-config-standard": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz", "integrity": "sha512-x4fmJL5hGqNJKGHSjnLdgA6U6h1YW/G2dW9fA+cyVur4SK6lyue8+UgNKWlZtUDTXvgKDD/Oa3GQjmB5kjtVvg==", - "dev": true, - "requires": {} + "dev": true }, "eslint-import-resolver-node": { "version": "0.3.6", @@ -14077,8 +14073,7 @@ "version": "5.2.0", "resolved": "https://registry.npmjs.org/eslint-plugin-promise/-/eslint-plugin-promise-5.2.0.tgz", "integrity": "sha512-SftLb1pUG01QYq2A/hGAWfDRXqYD82zE7j7TopDOyNdU+7SvvoXREls/+PRTY17vUXzXnZA/zfnyKgRH6x4JJw==", - "dev": true, - "requires": {} + "dev": true }, "eslint-plugin-react": { "version": "7.31.11", @@ -14129,8 +14124,7 @@ "version": "5.0.0", "resolved": "https://registry.npmjs.org/eslint-plugin-standard/-/eslint-plugin-standard-5.0.0.tgz", "integrity": "sha512-eSIXPc9wBM4BrniMzJRBm2uoVuXz2EPa+NXPk2+itrVt+r5SbKFERx/IgrK/HmfjddyKVz2f+j+7gBRvu19xLg==", - "dev": true, - "requires": {} + "dev": true }, "eslint-scope": { "version": "5.1.1", @@ -15881,8 +15875,7 @@ "version": "8.6.5", "resolved": "https://registry.npmjs.org/markdown-it-anchor/-/markdown-it-anchor-8.6.5.tgz", "integrity": "sha512-PI1qEHHkTNWT+X6Ip9w+paonfIQ+QZP9sCeMYi47oqhH+EsW8CrJ8J7CzV19QVOj6il8ATGbK2nTECj22ZHGvQ==", - "dev": true, - "requires": {} + "dev": true }, "marked": { "version": "4.2.3", @@ -17177,8 +17170,7 @@ "version": "5.2.3", "resolved": "https://registry.npmjs.org/react-frame-component/-/react-frame-component-5.2.3.tgz", "integrity": "sha512-r+h0o3r/uqOLNT724z4CRVkxQouKJvoi3OPfjqWACD30Y87rtEmeJrNZf1WYPGknn1Y8200HAjx7hY/dPUGgmA==", - "dev": true, - "requires": {} + "dev": true }, "react-is": { "version": "16.13.1", From 4c32c99de7cb4238af64669e6e6245ff4ab1cc0e Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Mon, 4 Nov 2024 15:18:28 +0530 Subject: [PATCH 17/18] chore(release): 1.46.4-recipe-schema.7 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index deea9ec1..56c228c2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.6", + "version": "1.46.4-recipe-schema.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.6", + "version": "1.46.4-recipe-schema.7", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index 842744d4..15b03a6c 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.46.4-recipe-schema.6", + "version": "1.46.4-recipe-schema.7", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo", From b193fdcde99574f3228308669b675594c0234ac8 Mon Sep 17 00:00:00 2001 From: VeenaYemmiganur Date: Tue, 12 Nov 2024 12:32:49 +0530 Subject: [PATCH 18/18] chore(release): 1.48.0-recipe-schema.0 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index d71ceb3d..00e57c7c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@quintype/seo", - "version": "1.47.0", + "version": "1.48.0-recipe-schema.0", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@quintype/seo", - "version": "1.47.0", + "version": "1.48.0-recipe-schema.0", "license": "MIT", "dependencies": { "date-fns": "^2.17.0", diff --git a/package.json b/package.json index ca05f19c..ec857844 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@quintype/seo", - "version": "1.47.0", + "version": "1.48.0-recipe-schema.0", "description": "SEO Modules for Quintype", "main": "dist/index.cjs.js", "repository": "https://github.com/quintype/quintype-node-seo",