@quintype/seo 1.38.42-subscription-markup.0 → 1.40.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/CHANGELOG.md CHANGED
@@ -2,6 +2,35 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ## [1.40.0](https://github.com/quintype/quintype-node-seo/compare/v1.38.37-fix-canonical-url.0...v1.40.0) (2021-12-16)
6
+
7
+
8
+ ### Features
9
+
10
+ * generate subscription based schema for news article ([#515](https://github.com/quintype/quintype-node-seo/issues/515)) ([39b2bad](https://github.com/quintype/quintype-node-seo/commit/39b2badaaa156ed6f01e8552e0d1f120b15361c0))
11
+ * **ImageTags:** Added support for og:image:alt and twitter:image:alt ([#501](https://github.com/quintype/quintype-node-seo/issues/501)) ([3d271ab](https://github.com/quintype/quintype-node-seo/commit/3d271ab21e009e0520ce1e6949bb1c8d32eeefa1))
12
+ * **Structure data tool testing:** Add support for testing structure data with all necessary schemas ⚡ ([#507](https://github.com/quintype/quintype-node-seo/issues/507)) ([aeea32a](https://github.com/quintype/quintype-node-seo/commit/aeea32a994bf4cf64cdf538d2ec3d785203b3817))
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * **pickImage:** image is undefined of pickImage ([#508](https://github.com/quintype/quintype-node-seo/issues/508)) ([fecc8be](https://github.com/quintype/quintype-node-seo/commit/fecc8be44c86220456a511a89d197b52d60875c6))
18
+
19
+ ## [1.39.0](https://github.com/quintype/quintype-node-seo/compare/v1.38.36...v1.39.0) (2021-08-23)
20
+
21
+
22
+ ### Features
23
+
24
+ * generate subscription based schema for news article ([#515](https://github.com/quintype/quintype-node-seo/issues/515)) ([39b2bad](https://github.com/quintype/quintype-node-seo/commit/39b2badaaa156ed6f01e8552e0d1f120b15361c0))
25
+ * **ImageTags:** Added support for og:image:alt and twitter:image:alt ([#501](https://github.com/quintype/quintype-node-seo/issues/501)) ([3d271ab](https://github.com/quintype/quintype-node-seo/commit/3d271ab21e009e0520ce1e6949bb1c8d32eeefa1))
26
+ * **Structure data tool testing:** Add support for testing structure data with all necessary schemas ⚡ ([#507](https://github.com/quintype/quintype-node-seo/issues/507)) ([aeea32a](https://github.com/quintype/quintype-node-seo/commit/aeea32a994bf4cf64cdf538d2ec3d785203b3817))
27
+
28
+
29
+ ### Bug Fixes
30
+
31
+ * **canonical:** remove canonical url for shell pages ([66cdebf](https://github.com/quintype/quintype-node-seo/commit/66cdebfb8f910adefa16d31d53f7e7473a06be4e))
32
+ * **pickImage:** image is undefined of pickImage ([#508](https://github.com/quintype/quintype-node-seo/issues/508)) ([fecc8be](https://github.com/quintype/quintype-node-seo/commit/fecc8be44c86220456a511a89d197b52d60875c6))
33
+
5
34
  ### [1.38.41](https://github.com/quintype/quintype-node-seo/compare/v1.38.41-news-article-schema.1...v1.38.41) (2021-08-17)
6
35
 
7
36
  ### [1.38.40](https://github.com/quintype/quintype-node-seo/compare/v1.38.39...v1.38.40) (2021-07-28)
package/dist/index.cjs.js CHANGED
@@ -471,11 +471,11 @@ function getSchemaType(type) {
471
471
  return { "@type": type };
472
472
  }
473
473
 
474
- function getSchemaPerson(name) {
474
+ function getSchemaPerson(name, url = "") {
475
475
  return Object.assign({}, getSchemaType("Person"), {
476
476
  givenName: name,
477
477
  name: name
478
- });
478
+ }, url && { url: url });
479
479
  }
480
480
 
481
481
  function getSchemaFooter({ cssSelector }) {
@@ -610,8 +610,14 @@ function generateCommonData(structuredData = {}, story = {}, publisherConfig = {
610
610
  }, getSchemaMainEntityOfPage(mainEntityUrl), getSchemaPublisher(structuredData.organization, orgUrl));
611
611
  }
612
612
 
613
- function authorData(authors) {
614
- return (authors || []).map(author => getSchemaPerson(author.name));
613
+ function authorData(authors = [], authorSchema = [], publisherConfig = {}) {
614
+ if (authorSchema.length > 0) {
615
+ return authorSchema.map(author => getSchemaPerson(author.name, author.url));
616
+ }
617
+ return authors.map(author => {
618
+ const authorUrl = author.slug ? `${publisherConfig["sketches-host"]}/author/${author.slug}` : null;
619
+ return getSchemaPerson(author.name, authorUrl);
620
+ });
615
621
  }
616
622
 
617
623
  function getTextElementsOfCards(story) {
@@ -649,8 +655,10 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
649
655
  const imageWidth = pageType === "story-page-amp" ? "1200" : "480";
650
656
  const imageHeight = pageType === "story-page-amp" ? "750" : "270";
651
657
  const storyAccessType = storyAccess(story["access"]);
658
+ const authorSchema = structuredData.authorSchema && structuredData.authorSchema(story) || [];
659
+
652
660
  return Object.assign({}, generateCommonData(structuredData, story, publisherConfig, pageType, timezone), {
653
- author: authorData(authors),
661
+ author: authorData(authors, authorSchema, publisherConfig),
654
662
  keywords: metaKeywords.join(","),
655
663
  thumbnailUrl: imageUrl(publisherConfig, story["hero-image-s3-key"], imageWidth, imageHeight),
656
664
  articleBody: storyKeysPresence && getCompleteText(story, structuredData.stripHtmlFromArticleBody) || "",
@@ -744,6 +752,7 @@ function findStoryElementField(card, type, field, defaultValue) {
744
752
  function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherConfig = {}, pageType, timezone) {
745
753
  const imageWidth = pageType === "story-page-amp" ? "1200" : "480";
746
754
  const imageHeight = pageType === "story-page-amp" ? "750" : "270";
755
+ const authorSchema = structuredData.authorSchema && structuredData.authorSchema(story) || [];
747
756
  return {
748
757
  headline: story.headline,
749
758
  description: story.summary || story.headline,
@@ -751,7 +760,7 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
751
760
  coverageEndTime: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
752
761
  coverageStartTime: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
753
762
  dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
754
- liveBlogUpdate: story.cards.map(card => getSchemaBlogPosting(card, authorData(story.authors), findStoryElementField(card, "title", "text", story.headline), imageUrl(publisherConfig, findStoryElementField(card, "image", "image-s3-key", story["hero-image-s3-key"]), imageWidth, imageHeight), structuredData, story, timezone))
763
+ liveBlogUpdate: story.cards.map(card => getSchemaBlogPosting(card, authorData(story.authors, authorSchema, publisherConfig), findStoryElementField(card, "title", "text", story.headline), imageUrl(publisherConfig, findStoryElementField(card, "image", "image-s3-key", story["hero-image-s3-key"]), imageWidth, imageHeight), structuredData, story, timezone))
755
764
  };
756
765
  }
757
766
 
@@ -765,8 +774,9 @@ function generateVideoArticleData(structuredData = {}, story = {}, publisherConf
765
774
  const headline = get__default['default'](story, ["headline"], "");
766
775
  const imageWidth = pageType === "story-page-amp" ? "1200" : "480";
767
776
  const imageHeight = pageType === "story-page-amp" ? "750" : "270";
777
+ const authorSchema = structuredData.authorSchema && structuredData.authorSchema(story) || [];
768
778
  return Object.assign({}, generateCommonData(structuredData, story, publisherConfig, pageType, timezone), {
769
- author: authorData(story.authors),
779
+ author: authorData(story.authors, authorSchema, publisherConfig),
770
780
  keywords: metaKeywords.join(","),
771
781
  dateCreated: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
772
782
  dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
@@ -880,6 +890,14 @@ function generateBreadcrumbListData(pageType = "", publisherConfig = {}, data =
880
890
  * @property {Array} structuredDataTags An array of tags describing the publisher. eg: `{structuredDataTags: ["section-page", "tag-page"]}`
881
891
  * @property {boolean} isSubscriptionsEnabled Enable subscription based schema (default false)
882
892
  * @property {boolean} isShowcaseProduct Should product type be showcase (default false, fallback: basic)
893
+ * @property {function} authorSchema Should override author-url in Person schema. We have to pass an array of authors with name and URL Eg: "authorSchema" : (story)=> getAuthorWithUrl(story, config); const getAuthorWithUrl = (story, config) => {
894
+ return story.authors.map((author)=>{
895
+ return {
896
+ name: author.name,
897
+ url: `${config['sketches-host']}/author/${author.id}`
898
+ }
899
+ })
900
+ }
883
901
  *
884
902
  */
885
903
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.38.42-subscription-markup.0",
3
+ "version": "1.40.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",
@@ -6,11 +6,16 @@ export function getSchemaType(type) {
6
6
  return { "@type": type };
7
7
  }
8
8
 
9
- export function getSchemaPerson(name) {
10
- return Object.assign({}, getSchemaType("Person"), {
11
- givenName: name,
12
- name: name,
13
- });
9
+ export function getSchemaPerson(name, url = "") {
10
+ return Object.assign(
11
+ {},
12
+ getSchemaType("Person"),
13
+ {
14
+ givenName: name,
15
+ name: name,
16
+ },
17
+ url && { url: url }
18
+ );
14
19
  }
15
20
 
16
21
  export function getSchemaFooter({ cssSelector }) {
@@ -59,8 +59,14 @@ function generateCommonData(structuredData = {}, story = {}, publisherConfig = {
59
59
  );
60
60
  }
61
61
 
62
- function authorData(authors) {
63
- return (authors || []).map((author) => getSchemaPerson(author.name));
62
+ function authorData(authors = [], authorSchema = [], publisherConfig = {}) {
63
+ if (authorSchema.length > 0) {
64
+ return authorSchema.map((author) => getSchemaPerson(author.name, author.url));
65
+ }
66
+ return authors.map((author) => {
67
+ const authorUrl = author.slug ? `${publisherConfig["sketches-host"]}/author/${author.slug}` : null;
68
+ return getSchemaPerson(author.name, authorUrl);
69
+ });
64
70
  }
65
71
 
66
72
  function getTextElementsOfCards(story) {
@@ -98,11 +104,13 @@ function generateArticleData(structuredData = {}, story = {}, publisherConfig =
98
104
  const imageWidth = pageType === "story-page-amp" ? "1200" : "480";
99
105
  const imageHeight = pageType === "story-page-amp" ? "750" : "270";
100
106
  const storyAccessType = storyAccess(story["access"]);
107
+ const authorSchema = (structuredData.authorSchema && structuredData.authorSchema(story)) || [];
108
+
101
109
  return Object.assign(
102
110
  {},
103
111
  generateCommonData(structuredData, story, publisherConfig, pageType, timezone),
104
112
  {
105
- author: authorData(authors),
113
+ author: authorData(authors, authorSchema, publisherConfig),
106
114
  keywords: metaKeywords.join(","),
107
115
  thumbnailUrl: imageUrl(publisherConfig, story["hero-image-s3-key"], imageWidth, imageHeight),
108
116
  articleBody: (storyKeysPresence && getCompleteText(story, structuredData.stripHtmlFromArticleBody)) || "",
@@ -219,6 +227,7 @@ function findStoryElementField(card, type, field, defaultValue) {
219
227
  function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherConfig = {}, pageType, timezone) {
220
228
  const imageWidth = pageType === "story-page-amp" ? "1200" : "480";
221
229
  const imageHeight = pageType === "story-page-amp" ? "750" : "270";
230
+ const authorSchema = (structuredData.authorSchema && structuredData.authorSchema(story)) || [];
222
231
  return {
223
232
  headline: story.headline,
224
233
  description: story.summary || story.headline,
@@ -229,7 +238,7 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
229
238
  liveBlogUpdate: story.cards.map((card) =>
230
239
  getSchemaBlogPosting(
231
240
  card,
232
- authorData(story.authors),
241
+ authorData(story.authors, authorSchema, publisherConfig),
233
242
  findStoryElementField(card, "title", "text", story.headline),
234
243
  imageUrl(
235
244
  publisherConfig,
@@ -255,8 +264,9 @@ function generateVideoArticleData(structuredData = {}, story = {}, publisherConf
255
264
  const headline = get(story, ["headline"], "");
256
265
  const imageWidth = pageType === "story-page-amp" ? "1200" : "480";
257
266
  const imageHeight = pageType === "story-page-amp" ? "750" : "270";
267
+ const authorSchema = (structuredData.authorSchema && structuredData.authorSchema(story)) || [];
258
268
  return Object.assign({}, generateCommonData(structuredData, story, publisherConfig, pageType, timezone), {
259
- author: authorData(story.authors),
269
+ author: authorData(story.authors, authorSchema, publisherConfig),
260
270
  keywords: metaKeywords.join(","),
261
271
  dateCreated: stripMillisecondsFromTime(new Date(story["first-published-at"]), timezone),
262
272
  dateModified: stripMillisecondsFromTime(new Date(story["last-published-at"]), timezone),
@@ -370,6 +380,14 @@ function generateBreadcrumbListData(pageType = "", publisherConfig = {}, data =
370
380
  * @property {Array} structuredDataTags An array of tags describing the publisher. eg: `{structuredDataTags: ["section-page", "tag-page"]}`
371
381
  * @property {boolean} isSubscriptionsEnabled Enable subscription based schema (default false)
372
382
  * @property {boolean} isShowcaseProduct Should product type be showcase (default false, fallback: basic)
383
+ * @property {function} authorSchema Should override author-url in Person schema. We have to pass an array of authors with name and URL Eg: "authorSchema" : (story)=> getAuthorWithUrl(story, config); const getAuthorWithUrl = (story, config) => {
384
+ return story.authors.map((author)=>{
385
+ return {
386
+ name: author.name,
387
+ url: `${config['sketches-host']}/author/${author.id}`
388
+ }
389
+ })
390
+ }
373
391
  *
374
392
  */
375
393