@quintype/seo 1.40.6-embed-url.4 → 1.40.7-amphtml-issue.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.
@@ -3,8 +3,8 @@
3
3
  "editor.defaultFormatter": "esbenp.prettier-vscode"
4
4
  },
5
5
  "editor.tabSize": 2,
6
- "editor.detectIndentation": false,
7
6
  "editor.formatOnSave": true,
7
+ "editor.detectIndentation": false,
8
8
  "files.insertFinalNewline": true,
9
9
  "files.trimTrailingWhitespace": true,
10
10
  "editor.codeActionsOnSave": {
package/CHANGELOG.md CHANGED
@@ -2,14 +2,6 @@
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.5](https://github.com/quintype/quintype-node-seo/compare/v1.40.1...v1.40.5) (2022-06-30)
6
-
7
-
8
- ### Bug Fixes
9
-
10
- * og image for stories with no image | fallback og image ([454aef9](https://github.com/quintype/quintype-node-seo/commit/454aef9e0a1bc5acfde1aa56d223c518255376a2))
11
- * Update image schema ([#522](https://github.com/quintype/quintype-node-seo/issues/522)) ([5e42cdc](https://github.com/quintype/quintype-node-seo/commit/5e42cdcbb14d587251b7a3f932a4f98dd358f188))
12
-
13
5
  ### [1.40.4](https://github.com/quintype/quintype-node-seo/compare/v1.40.4-amptag.0...v1.40.4) (2022-03-22)
14
6
 
15
7
  ### [1.40.3](https://github.com/quintype/quintype-node-seo/compare/v1.40.2...v1.40.3) (2022-02-23)
package/dist/index.cjs.js CHANGED
@@ -159,33 +159,6 @@ function buildCustomTags(customTags = {}, pageType = "") {
159
159
  return {};
160
160
  }
161
161
 
162
- function buildTagsFromStaticPage(config, page, url = {}, data) {
163
- const seoData = lodash.get(page, ["metadata", "seo"], {});
164
- const customSeo = lodash.get(data, ["data", "customSeo"], {});
165
- if (lodash.isEmpty(seoData) && lodash.isEmpty(customSeo)) return;
166
-
167
- const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
168
-
169
- const title = customSeo.title || metaTitle || page.title;
170
- const pageTitle = customSeo["page-title"] || title;
171
- const description = customSeo.description || metaDescription;
172
- const ogTitle = customSeo.ogTitle || title;
173
- const staticPageUrl = `${config["sketches-host"]}${url.pathname}`;
174
- const ogDescription = customSeo.ogDescription || description;
175
-
176
- return {
177
- title,
178
- "page-title": pageTitle,
179
- description,
180
- keywords: `${title},${config["publisher-name"]}`,
181
- canonicalUrl: staticPageUrl,
182
- ogUrl: staticPageUrl,
183
- ogTitle,
184
- ogDescription,
185
- keywords: customSeo.keywords || keywords
186
- };
187
- }
188
-
189
162
  // The findRelevantConfig method call has no ownerId for home page.
190
163
  // This causes the seoMetadata to be undefined.
191
164
  // So the default value for the ownerId is set to null.
@@ -242,8 +215,6 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
242
215
  return buildTagsFromStory(config, lodash.get(data, ["data", "story"]), url, data) || getSeoData(config, "home-page", data, url);
243
216
  case "author-page":
244
217
  return buildTagsFromAuthor(config, lodash.get(data, ["data", "author"], {}), url, data) || getSeoData(config, "home-page", data, url);
245
- case "static-page":
246
- return buildTagsFromStaticPage(config, lodash.get(data, ["data", "page"], {}), url, data) || getSeoData(config, "home-page", data, url);
247
218
  case "shell":
248
219
  return getShellSeoData(config);
249
220
  default:
@@ -820,30 +791,9 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
820
791
  };
821
792
  }
822
793
 
823
- function getEmbedUrl(cards) {
824
- let embedUrl = "";
825
-
826
- // not using the return value of top level find
827
- // coz we only need the embed url
828
- // find is used for early exit
829
- cards.find(card => {
830
- const storyElements = card["story-elements"];
831
- return storyElements.find((elem, index) => {
832
- if (elem["embed-url"]) {
833
- embedUrl = elem["embed-url"];
834
- return true;
835
- }
836
- return false;
837
- });
838
- });
839
-
840
- return embedUrl;
841
- }
842
-
843
794
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
844
795
  const metaKeywords = story.seo && story.seo["meta-keywords"] || [];
845
- const storyCards = get__default["default"](story, ["cards"], []);
846
- const embedUrl = getEmbedUrl(storyCards);
796
+ const embedUrl = get__default["default"](story, ["cards", "0", "story-elements", "0", "embed-url"], "");
847
797
  const socialShareMsg = get__default["default"](story, ["summary"], "");
848
798
  const metaDescription = get__default["default"](story, ["seo", "meta-description"], "");
849
799
  const subHeadline = get__default["default"](story, ["subheadline"], "");
@@ -1109,11 +1059,13 @@ function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
1109
1059
  // TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
1110
1060
  const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
1111
1061
  const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
1062
+ const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
1063
+
1112
1064
  if (showAmpTag(seoConfig, pageType, story)) {
1113
1065
  return [{
1114
1066
  tag: 'link',
1115
1067
  rel: 'amphtml',
1116
- href: `${ampUrlAppend}/amp/story/${storySlug}`
1068
+ href: ampUrl
1117
1069
  }];
1118
1070
  } else {
1119
1071
  return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.40.6-embed-url.4",
3
+ "version": "1.40.7-amphtml-issue.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",
package/src/amp-tags.js CHANGED
@@ -40,11 +40,13 @@ export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
40
40
  // TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
41
41
  const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config['sketches-host'] : '';
42
42
  const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug): encodeURIComponent(story.slug);
43
+ const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
44
+
43
45
  if (showAmpTag(seoConfig, pageType, story)) {
44
46
  return [{
45
47
  tag: 'link',
46
48
  rel: 'amphtml',
47
- href: `${ampUrlAppend}/amp/story/${storySlug}`
49
+ href: ampUrl
48
50
  }];
49
51
  } else {
50
52
  return [];
@@ -254,31 +254,9 @@ function generateLiveBlogPostingData(structuredData = {}, story = {}, publisherC
254
254
  };
255
255
  }
256
256
 
257
- function getEmbedUrl(cards) {
258
- let embedUrl = "";
259
-
260
- // not using the return value of top level find
261
- // coz we only need the embed url
262
- // find is used for early exit
263
- cards.find((card) => {
264
- const storyElements = card["story-elements"];
265
- return storyElements.find((elem, index) => {
266
- if (elem["embed-url"]) {
267
- embedUrl = elem["embed-url"];
268
- return true;
269
- }
270
- return false;
271
- });
272
- });
273
-
274
- return embedUrl;
275
- }
276
-
277
-
278
257
  function generateVideoArticleData(structuredData = {}, story = {}, publisherConfig = {}, timezone) {
279
258
  const metaKeywords = (story.seo && story.seo["meta-keywords"]) || [];
280
- const storyCards = get(story, ["cards"], []);
281
- const embedUrl = getEmbedUrl(storyCards);
259
+ const embedUrl = get(story, ["cards", "0", "story-elements", "0", "embed-url"], "");
282
260
  const socialShareMsg = get(story, ["summary"], "");
283
261
  const metaDescription = get(story, ["seo", "meta-description"], "");
284
262
  const subHeadline = get(story, ["subheadline"], "");
@@ -498,7 +476,10 @@ export function StructuredDataTags({ structuredData = {} }, config, pageType, re
498
476
  }
499
477
 
500
478
  if (structuredData.enableVideo && story["story-template"] === "video") {
501
- return ldJson("VideoObject", generateVideoArticleData(structuredData, story, publisherConfig, timezone));
479
+ return ldJson(
480
+ "VideoObject",
481
+ generateVideoArticleData(structuredData, story, publisherConfig, timezone)
482
+ );
502
483
  }
503
484
 
504
485
  if (structuredData.enableNewsArticle !== "withoutArticleSchema") {
package/src/text-tags.js CHANGED
@@ -112,33 +112,6 @@ function buildCustomTags(customTags = {}, pageType = "") {
112
112
  return {};
113
113
  }
114
114
 
115
- function buildTagsFromStaticPage(config, page, url = {}, data) {
116
- const seoData = get(page, ["metadata", "seo"], {});
117
- const customSeo = get(data, ["data", "customSeo"], {});
118
- if (isEmpty(seoData) && isEmpty(customSeo)) return;
119
-
120
- const { "meta-title": metaTitle, "meta-description": metaDescription, "meta-keywords": keywords } = seoData;
121
-
122
- const title = customSeo.title || metaTitle || page.title;
123
- const pageTitle = customSeo["page-title"] || title;
124
- const description = customSeo.description || metaDescription;
125
- const ogTitle = customSeo.ogTitle || title;
126
- const staticPageUrl = `${config["sketches-host"]}${url.pathname}`;
127
- const ogDescription = customSeo.ogDescription || description;
128
-
129
- return {
130
- title,
131
- "page-title": pageTitle,
132
- description,
133
- keywords: `${title},${config["publisher-name"]}`,
134
- canonicalUrl: staticPageUrl,
135
- ogUrl: staticPageUrl,
136
- ogTitle,
137
- ogDescription,
138
- keywords: customSeo.keywords || keywords,
139
- };
140
- }
141
-
142
115
  // The findRelevantConfig method call has no ownerId for home page.
143
116
  // This causes the seoMetadata to be undefined.
144
117
  // So the default value for the ownerId is set to null.
@@ -215,11 +188,6 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
215
188
  buildTagsFromAuthor(config, get(data, ["data", "author"], {}), url, data) ||
216
189
  getSeoData(config, "home-page", data, url)
217
190
  );
218
- case "static-page":
219
- return (
220
- buildTagsFromStaticPage(config, get(data, ["data", "page"], {}), url, data) ||
221
- getSeoData(config, "home-page", data, url)
222
- );
223
191
  case "shell":
224
192
  return getShellSeoData(config);
225
193
  default:
@@ -19,6 +19,12 @@ describe('AmpTags', function () {
19
19
  assertContains('<link rel="amphtml" href="/amp/story/section%2Fslug"/>', string);
20
20
  });
21
21
 
22
+ it("it does not append `/amp/story` to the amp tag when it's a visual story", function () {
23
+ const story = { slug: "section/slug", "is-amp-supported": true };
24
+ const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: { ...story, "story-template": "visual-story" } } }, {});
25
+ assertContains('<link rel="amphtml" href="/section%2Fslug"/>', string);
26
+ });
27
+
22
28
  it("does not rely on is-amp-supported in story API", function () {
23
29
  const story = { slug: "section/slug", "is-amp-supported": false };
24
30
  const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});