@quintype/seo 1.41.3 → 1.41.4

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,8 @@
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.41.4](https://github.com/quintype/quintype-node-seo/compare/v1.41.4-gsc-errors-fix.0...v1.41.4) (2022-12-12)
6
+
5
7
  ### [1.41.3](https://github.com/quintype/quintype-node-seo/compare/v1.41.2...v1.41.3) (2022-12-02)
6
8
 
7
9
  ### [1.41.2](https://github.com/quintype/quintype-node-seo/compare/v1.41.1...v1.41.2) (2022-11-30)
package/dist/index.cjs.js CHANGED
@@ -78,16 +78,18 @@ const getDomain = (url, domainSlug) => {
78
78
  * @param {(boolean|"public")} seoConfig.ampStoryPages Should amp story pages be shown for all stories (true), not shown (false), or only be shown for public stories ("public"). Default: true
79
79
  * @param {(boolean)} seoConfig.appendHostToAmpUrl If set to true, the url to be appended to the slug is computed based on the currentHostUrl and the domain slug, else the url is taken as the sketches host. Default: false
80
80
  * @param {(boolean)} seoConfig.decodeAmpUrl If set to true, the storySlug that goes as the amp href url is decoded, else the storyslug is encoded. Default: false
81
+ * @param {(boolean)} seoConfig.ignoreAmpHtmlStoryTemplates pass all the story templates you want to ignore from add rel="amphtml" tag. Default: ["visual story"]
81
82
  * @param {...*} params See {@link Generator} for other Parameters
82
83
  */
83
84
  function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
85
+ const templatesToIgnore = seoConfig.ignoreAmpHtmlStoryTemplates || ["visual-story"];
84
86
  const story = get__default["default"](data, ["data", "story"], {});
85
87
  const { currentHostUrl = "", domainSlug } = data;
86
88
  // TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
87
89
  const ampUrlAppend = seoConfig.appendHostToAmpUrl ? getDomain(currentHostUrl, domainSlug) || config["sketches-host"] : "";
88
90
  const storySlug = seoConfig.decodeAmpUrl ? decodeURIComponent(story.slug) : encodeURIComponent(story.slug);
89
91
  const ampUrl = story["story-template"] === "visual-story" ? `${ampUrlAppend}/${storySlug}` : `${ampUrlAppend}/amp/story/${storySlug}`;
90
- const ignoreStoryTemplate = seoConfig.ignoreAmpHtmlStoryTemplates && seoConfig.ignoreAmpHtmlStoryTemplates.includes(story["story-template"]);
92
+ const ignoreStoryTemplate = templatesToIgnore.includes(story["story-template"]);
91
93
  if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
92
94
  return [{
93
95
  tag: "link",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.41.3",
3
+ "version": "1.41.4",
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
@@ -30,9 +30,11 @@ const getDomain = (url, domainSlug) => {
30
30
  * @param {(boolean|"public")} seoConfig.ampStoryPages Should amp story pages be shown for all stories (true), not shown (false), or only be shown for public stories ("public"). Default: true
31
31
  * @param {(boolean)} seoConfig.appendHostToAmpUrl If set to true, the url to be appended to the slug is computed based on the currentHostUrl and the domain slug, else the url is taken as the sketches host. Default: false
32
32
  * @param {(boolean)} seoConfig.decodeAmpUrl If set to true, the storySlug that goes as the amp href url is decoded, else the storyslug is encoded. Default: false
33
+ * @param {(boolean)} seoConfig.ignoreAmpHtmlStoryTemplates pass all the story templates you want to ignore from add rel="amphtml" tag. Default: ["visual story"]
33
34
  * @param {...*} params See {@link Generator} for other Parameters
34
35
  */
35
36
  export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
37
+ const templatesToIgnore = seoConfig.ignoreAmpHtmlStoryTemplates || ["visual-story"];
36
38
  const story = get(data, ["data", "story"], {});
37
39
  const { currentHostUrl = "", domainSlug } = data;
38
40
  // TODO: Remove this condition and always make absolute URL if that's better for AMP discoverability.
@@ -44,8 +46,7 @@ export function StoryAmpTags(seoConfig, config, pageType, data = {}, opts) {
44
46
  story["story-template"] === "visual-story"
45
47
  ? `${ampUrlAppend}/${storySlug}`
46
48
  : `${ampUrlAppend}/amp/story/${storySlug}`;
47
- const ignoreStoryTemplate =
48
- seoConfig.ignoreAmpHtmlStoryTemplates && seoConfig.ignoreAmpHtmlStoryTemplates.includes(story["story-template"]);
49
+ const ignoreStoryTemplate = templatesToIgnore.includes(story["story-template"]);
49
50
  if (showAmpTag(seoConfig, pageType, story) && !ignoreStoryTemplate) {
50
51
  return [
51
52
  {
@@ -1,9 +1,9 @@
1
1
  const { StoryAmpTags } = require("..");
2
2
  const { getSeoMetadata, assertContains } = require("./utils");
3
3
 
4
- const assert = require('assert');
4
+ const assert = require("assert");
5
5
 
6
- describe('AmpTags', function () {
6
+ describe("AmpTags", function () {
7
7
  const seoConfig = {
8
8
  generators: [StoryAmpTags],
9
9
  ampStoryPages: true,
@@ -19,12 +19,6 @@ 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
-
28
22
  it("does not rely on is-amp-supported in story API", function () {
29
23
  const story = { slug: "section/slug", "is-amp-supported": false };
30
24
  const string = getSeoMetadata(seoConfig, config, "story-page", { data: { story: story } }, {});