@quintype/seo 1.40.14 → 1.40.15-metadata-404.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
@@ -983,6 +983,33 @@ function buildTagsFromTopic(config, tag, url = {}, data) {
983
983
  return topicMetaData;
984
984
  }
985
985
 
986
+ function buildTagsFromNotfoundPage(config, url = {}, data) {
987
+ const homeSeoData = config["seo-metadata"].find(page => page["owner-type"] === "home") || {
988
+ data: { description: "" }
989
+ };
990
+ const customSeo = lodash.get(data, ["data", "customSeo"], {});
991
+ const title = customSeo.title || "404 - Page not found ";
992
+ const pageTitle = customSeo["page-title"] || title;
993
+ const description = customSeo.description || homeSeoData.data.description || "404 - Page not found";
994
+ const pageUrl = `${config["sketches-host"]}${url.pathname}`;
995
+ const canonicalSlug = url.pathname;
996
+ const canonicalUrl = `${config["sketches-host"]}${canonicalSlug}`;
997
+ const ogTitle = customSeo.ogTitle || title;
998
+ const ogDescription = customSeo.ogDescription || description;
999
+ const notFoundMetaData = {
1000
+ title: title,
1001
+ "page-title": pageTitle,
1002
+ description: description,
1003
+ keywords: title,
1004
+ canonicalUrl,
1005
+ ogUrl: pageUrl,
1006
+ ogTitle,
1007
+ ogDescription
1008
+ };
1009
+
1010
+ return notFoundMetaData;
1011
+ }
1012
+
986
1013
  function buildTagsFromAuthor(config, author, url = {}, data) {
987
1014
  if (lodash.isEmpty(author)) return;
988
1015
 
@@ -1099,6 +1126,8 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
1099
1126
  return buildTagsFromAuthor(config, lodash.get(data, ["data", "author"], {}), url, data) || getSeoData(config, "home-page", data, url);
1100
1127
  case "static-page":
1101
1128
  return buildTagsFromStaticPage(config, lodash.get(data, ["data", "page"], {}), url, data) || getSeoData(config, "home-page", data, url);
1129
+ case "not-found":
1130
+ return buildTagsFromNotfoundPage(config, url, data) || getSeoData(config, "home-page", data, url);
1102
1131
  case "shell":
1103
1132
  return getShellSeoData(config);
1104
1133
  default:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@quintype/seo",
3
- "version": "1.40.14",
3
+ "version": "1.40.15-metadata-404.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/text-tags.js CHANGED
@@ -81,6 +81,33 @@ function buildTagsFromTopic(config, tag, url = {}, data) {
81
81
  return topicMetaData;
82
82
  }
83
83
 
84
+ function buildTagsFromNotfoundPage(config, url = {}, data) {
85
+ const homeSeoData = config["seo-metadata"].find((page) => page["owner-type"] === "home") || {
86
+ data: { description: "" },
87
+ };
88
+ const customSeo = get(data, ["data", "customSeo"], {});
89
+ const title = customSeo.title || "404 - Page not found ";
90
+ const pageTitle = customSeo["page-title"] || title;
91
+ const description = customSeo.description || homeSeoData.data.description || "404 - Page not found";
92
+ const pageUrl = `${config["sketches-host"]}${url.pathname}`;
93
+ const canonicalSlug = url.pathname;
94
+ const canonicalUrl = `${config["sketches-host"]}${canonicalSlug}`;
95
+ const ogTitle = customSeo.ogTitle || title;
96
+ const ogDescription = customSeo.ogDescription || description;
97
+ const notFoundMetaData = {
98
+ title: title,
99
+ "page-title": pageTitle,
100
+ description: description,
101
+ keywords: title,
102
+ canonicalUrl,
103
+ ogUrl: pageUrl,
104
+ ogTitle,
105
+ ogDescription,
106
+ };
107
+
108
+ return notFoundMetaData;
109
+ }
110
+
84
111
  function buildTagsFromAuthor(config, author, url = {}, data) {
85
112
  if (isEmpty(author)) return;
86
113
 
@@ -220,6 +247,8 @@ function getSeoData(config, pageType, data, url = {}, seoConfig = {}) {
220
247
  buildTagsFromStaticPage(config, get(data, ["data", "page"], {}), url, data) ||
221
248
  getSeoData(config, "home-page", data, url)
222
249
  );
250
+ case "not-found":
251
+ return buildTagsFromNotfoundPage(config, url, data) || getSeoData(config, "home-page", data, url);
223
252
  case "shell":
224
253
  return getShellSeoData(config);
225
254
  default: