@quintype/seo 1.47.0 → 1.48.0-recipe-schema.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs.js CHANGED
@@ -550,6 +550,33 @@ function generateAuthorPageSchema(publisherConfig, data, url) {
550
550
  };
551
551
  }
552
552
 
553
+ function generateRecipePageSchema(story) {
554
+ const { headline, url, "author-name": authorName, description, metadata } = story;
555
+ const servings = lodash.get(metadata, ["servings"], "");
556
+ const ingredients = lodash.get(metadata, ["ingredients"], "");
557
+ const recipeAttributes = lodash.get(metadata, ["story-attributes"], "");
558
+ const cuisine = lodash.get(recipeAttributes, ["cuisine", "0"], "");
559
+ const preperationtime = lodash.get(recipeAttributes, ["preparationtime", "0"], "");
560
+ const cookingtime = lodash.get(recipeAttributes, ["cookingtime", "0"], "");
561
+
562
+ return {
563
+ "@context": "https://schema.org/",
564
+ "@type": "Recipe",
565
+ name: headline,
566
+ url: url,
567
+ author: {
568
+ "@type": "Person",
569
+ name: authorName
570
+ },
571
+ description: description,
572
+ recipeIngredient: ingredients,
573
+ prepTime: preperationtime,
574
+ cookTime: cookingtime,
575
+ recipeCuisine: cuisine,
576
+ recipeYield: servings
577
+ };
578
+ }
579
+
553
580
  function getMovieEntityTags(movieJson) {
554
581
  return getSchemaMovieReview(movieJson);
555
582
  }
@@ -960,7 +987,6 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
960
987
  const isStructuredDataEmpty = Object.keys(structuredData).length === 0;
961
988
  const enableBreadcrumbList = get__default["default"](structuredData, ["enableBreadcrumbList"], true);
962
989
  const structuredDataTags = get__default["default"](structuredData, ["structuredDataTags"], []);
963
-
964
990
  let articleData = {};
965
991
 
966
992
  if (!isStructuredDataEmpty) {
@@ -989,11 +1015,33 @@ function StructuredDataTags({ structuredData = {} }, config, pageType, response
989
1015
  if (!isStructuredDataEmpty && pageType === "story-page") {
990
1016
  const newsArticleTags = generateNewsArticleTags();
991
1017
  newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
1018
+ if (story["story-template"] === "recipe") {
1019
+ const recipeTags = generateRecipePageSchema(story);
1020
+ recipeTags.image = Object.assign({
1021
+ "@type": "ImageObject"
1022
+ }, generateArticleImageData(story["hero-image-s3-key"], publisherConfig));
1023
+ recipeTags.video = Object.assign({
1024
+ "@type": "VideoObject"
1025
+ }, generateVideoArticleData(structuredData, story, publisherConfig, timezone));
1026
+
1027
+ tags.push(ldJson("Recipe", recipeTags));
1028
+ }
992
1029
  }
993
1030
 
994
1031
  if (!isStructuredDataEmpty && pageType === "story-page-amp") {
995
1032
  const newsArticleTags = generateNewsArticleTags();
996
1033
  newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
1034
+ if (story["story-template"] === "recipe") {
1035
+ const recipeTags = generateRecipePageSchema(story);
1036
+ recipeTags.image = Object.assign({
1037
+ "@type": "ImageObject"
1038
+ }, generateArticleImageData(story["hero-image-s3-key"], publisherConfig));
1039
+ recipeTags.video = Object.assign({
1040
+ "@type": "VideoObject"
1041
+ }, generateVideoArticleData(structuredData, story, publisherConfig, timezone));
1042
+
1043
+ tags.push(ldJson("Recipe", recipeTags));
1044
+ }
997
1045
  }
998
1046
 
999
1047
  if (!isStructuredDataEmpty && structuredData.header) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.47.0",
3
+ "version": "1.48.0-recipe-schema.0",
4
4
  "description": "SEO Modules for Quintype",
5
5
  "main": "dist/index.cjs.js",
6
6
  "repository": "https://github.com/quintype/quintype-node-seo",
@@ -141,3 +141,30 @@ export function generateAuthorPageSchema(publisherConfig, data, url) {
141
141
  },
142
142
  };
143
143
  }
144
+
145
+ export function generateRecipePageSchema(story) {
146
+ const { headline, url, "author-name": authorName, description, metadata } = story;
147
+ const servings = get(metadata, ["servings"], "");
148
+ const ingredients = get(metadata, ["ingredients"], "");
149
+ const recipeAttributes = get(metadata, ["story-attributes"], "");
150
+ const cuisine = get(recipeAttributes, ["cuisine", "0"], "");
151
+ const preperationtime = get(recipeAttributes, ["preparationtime", "0"], "");
152
+ const cookingtime = get(recipeAttributes, ["cookingtime", "0"], "");
153
+
154
+ return {
155
+ "@context": "https://schema.org/",
156
+ "@type": "Recipe",
157
+ name: headline,
158
+ url: url,
159
+ author: {
160
+ "@type": "Person",
161
+ name: authorName,
162
+ },
163
+ description: description,
164
+ recipeIngredient: ingredients,
165
+ prepTime: preperationtime,
166
+ cookTime: cookingtime,
167
+ recipeCuisine: cuisine,
168
+ recipeYield: servings,
169
+ };
170
+ }
@@ -3,6 +3,7 @@ import { getQueryParams, stripMillisecondsFromTime } from "../utils";
3
3
  import { generateTagsForEntity } from "./entity";
4
4
  import {
5
5
  generateAuthorPageSchema,
6
+ generateRecipePageSchema,
6
7
  getSchemaBlogPosting,
7
8
  getSchemaBreadcrumbList,
8
9
  getSchemaContext,
@@ -472,7 +473,6 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
472
473
  const isStructuredDataEmpty = Object.keys(structuredData).length === 0;
473
474
  const enableBreadcrumbList = get(structuredData, ["enableBreadcrumbList"], true);
474
475
  const structuredDataTags = get(structuredData, ["structuredDataTags"], []);
475
-
476
476
  let articleData = {};
477
477
 
478
478
  if (!isStructuredDataEmpty) {
@@ -501,11 +501,45 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
501
501
  if (!isStructuredDataEmpty && pageType === "story-page") {
502
502
  const newsArticleTags = generateNewsArticleTags();
503
503
  newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
504
+ if (story["story-template"] === "recipe") {
505
+ const recipeTags = generateRecipePageSchema(story);
506
+ recipeTags.image = Object.assign(
507
+ {
508
+ "@type": "ImageObject",
509
+ },
510
+ generateArticleImageData(story["hero-image-s3-key"], publisherConfig)
511
+ );
512
+ recipeTags.video = Object.assign(
513
+ {
514
+ "@type": "VideoObject",
515
+ },
516
+ generateVideoArticleData(structuredData, story, publisherConfig, timezone)
517
+ );
518
+
519
+ tags.push(ldJson("Recipe", recipeTags));
520
+ }
504
521
  }
505
522
 
506
523
  if (!isStructuredDataEmpty && pageType === "story-page-amp") {
507
524
  const newsArticleTags = generateNewsArticleTags();
508
525
  newsArticleTags ? tags.push(storyTags(), newsArticleTags) : tags.push(storyTags());
526
+ if (story["story-template"] === "recipe") {
527
+ const recipeTags = generateRecipePageSchema(story);
528
+ recipeTags.image = Object.assign(
529
+ {
530
+ "@type": "ImageObject",
531
+ },
532
+ generateArticleImageData(story["hero-image-s3-key"], publisherConfig)
533
+ );
534
+ recipeTags.video = Object.assign(
535
+ {
536
+ "@type": "VideoObject",
537
+ },
538
+ generateVideoArticleData(structuredData, story, publisherConfig, timezone)
539
+ );
540
+
541
+ tags.push(ldJson("Recipe", recipeTags));
542
+ }
509
543
  }
510
544
 
511
545
  if (!isStructuredDataEmpty && structuredData.header) {