@quintype/seo 1.41.5-description-fallback.1 → 1.41.5-description-fallback.2

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
@@ -6,8 +6,8 @@ var lodash = require('lodash');
6
6
  var React = require('react');
7
7
  var ReactDomServer = require('react-dom/server');
8
8
  var get = require('lodash/get');
9
- var url = require('url');
10
9
  var dateFnsTz = require('date-fns-tz');
10
+ var url = require('url');
11
11
  var isUndefined = require('lodash/isUndefined');
12
12
  var omitBy = require('lodash/omitBy');
13
13
  var quintypeJs = require('quintype-js');
@@ -51,7 +51,7 @@ function isStoryPublic(story) {
51
51
 
52
52
  function getTextOfCards(story) {
53
53
  if (story && story.cards) {
54
- story.cards.map(item => {
54
+ return story.cards.map(item => {
55
55
  return item['story-elements'].reduce((acc, currentItem) => {
56
56
  const elementType = currentItem.subtype || currentItem.type || '';
57
57
  if (elementType === 'text') {
@@ -968,11 +968,13 @@ function buildTagsFromStory(config, story, url = {}, data = {}, seoConfig = {})
968
968
 
969
969
  let descriptionWithExtraFallback = "";
970
970
  let ogDescriptionWithExtraFallback = "";
971
- if (seoConfig.enableMetaDescriptionFallback) {
971
+ const enableMetaDescriptionFallback = lodash.get(seoConfig, ["enableMetaDescriptionFallback"], false);
972
+ if (enableMetaDescriptionFallback) {
973
+ const subHeadline = lodash.get(story, ["subheadline"]);
972
974
  const fetch160Characters = data => data ? data.substring(0, 160) : null;
973
975
  const fullStoryTextElementContent = getTextOfCards(story);
974
- descriptionWithExtraFallback = fetch160Characters(story.subheadline) || fetch160Characters(fullStoryTextElementContent);
975
- ogDescriptionWithExtraFallback = fetch160Characters(fullStoryTextElementContent) || fetch160Characters(story.subheadline) || seo["meta-description"];
976
+ descriptionWithExtraFallback = fetch160Characters(subHeadline) || fetch160Characters(fullStoryTextElementContent);
977
+ ogDescriptionWithExtraFallback = fetch160Characters(fullStoryTextElementContent) || fetch160Characters(subHeadline) || lodash.get(seo, ["meta-description"]);
976
978
  }
977
979
 
978
980
  const storyUrl = story.url || `${config["sketches-host"]}/${story.slug}`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.41.5-description-fallback.1",
3
+ "version": "1.41.5-description-fallback.2",
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/text-tags.js CHANGED
@@ -24,15 +24,16 @@ function buildTagsFromStory(config, story, url = {}, data = {}, seoConfig = {})
24
24
 
25
25
  let descriptionWithExtraFallback = "";
26
26
  let ogDescriptionWithExtraFallback = "";
27
- if (seoConfig.enableMetaDescriptionFallback) {
27
+ const enableMetaDescriptionFallback = get(seoConfig, ["enableMetaDescriptionFallback"], false);
28
+ if (enableMetaDescriptionFallback) {
29
+ const subHeadline = get(story, ["subheadline"]);
28
30
  const fetch160Characters = (data) => (data ? data.substring(0, 160) : null);
29
31
  const fullStoryTextElementContent = getTextOfCards(story);
30
- descriptionWithExtraFallback =
31
- fetch160Characters(story.subheadline) || fetch160Characters(fullStoryTextElementContent);
32
+ descriptionWithExtraFallback = fetch160Characters(subHeadline) || fetch160Characters(fullStoryTextElementContent);
32
33
  ogDescriptionWithExtraFallback =
33
34
  fetch160Characters(fullStoryTextElementContent) ||
34
- fetch160Characters(story.subheadline) ||
35
- seo["meta-description"];
35
+ fetch160Characters(subHeadline) ||
36
+ get(seo, ["meta-description"]);
36
37
  }
37
38
 
38
39
  const storyUrl = story.url || `${config["sketches-host"]}/${story.slug}`;
package/src/utils.js CHANGED
@@ -1,6 +1,6 @@
1
- import {entries} from 'lodash';
2
- import { URL, URLSearchParams } from 'url';
3
1
  import { format, utcToZonedTime } from 'date-fns-tz';
2
+ import { entries } from 'lodash';
3
+ import { URL, URLSearchParams } from 'url';
4
4
 
5
5
  export function objectToTags(object) {
6
6
  return entries(object)
@@ -36,7 +36,7 @@ export function isStoryPublic(story) {
36
36
 
37
37
  export function getTextOfCards(story) {
38
38
  if (story && story.cards) {
39
- story.cards
39
+ return story.cards
40
40
  .map((item) => {
41
41
  return item['story-elements'].reduce((acc, currentItem) => {
42
42
  const elementType = currentItem.subtype || currentItem.type || '';