gatsby-plugin-advanced-sitemap-patch
Advanced tools
Comparing version 2.1.4 to 2.1.5
@@ -25,4 +25,2 @@ "use strict"; | ||
var _helpers = require("./helpers"); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
@@ -84,3 +82,3 @@ | ||
if (r.data[source] && Array.isArray(r.data[source].edges)) { | ||
var serializedEdges = mapping[source].serializer(r.data[source].edges); | ||
var serializedEdges = mapping[source].serializer(r.data[source].edges, r.data); | ||
@@ -96,10 +94,15 @@ if (!Array.isArray(serializedEdges)) { | ||
if ((_r$data = r.data) !== null && _r$data !== void 0 && (_r$data$source = _r$data[source]) !== null && _r$data$source !== void 0 && _r$data$source.edges && r.data[source].edges.length) { | ||
if ((_r$data = r.data) !== null && _r$data !== void 0 && (_r$data$source = _r$data[source]) !== null && _r$data$source !== void 0 && _r$data$source.edges && r.data[source].edges.length && source !== "site") { | ||
r.data[source].edges = r.data[source].edges.filter(function (_ref4) { | ||
var node = _ref4.node; | ||
return !exclude.some(function (excludedRoute) { | ||
var _node$fields; | ||
var _node$fields, _node$fields$slug, _node$slug; | ||
var sourceType = node.__typename ? "all" + node.__typename : source; | ||
var slug = sourceType === "allMarkdownRemark" || sourceType === "allMdx" || node !== null && node !== void 0 && (_node$fields = node.fields) !== null && _node$fields !== void 0 && _node$fields.slug ? node.fields.slug.replace(/^\/|\/$/, "") : node.slug.replace(/^\/|\/$/, ""); | ||
var sourceType = node !== null && node !== void 0 && node.__typename ? "all" + node.__typename : source; | ||
var slug = sourceType === "allMarkdownRemark" || sourceType === "allMdx" || node !== null && node !== void 0 && (_node$fields = node.fields) !== null && _node$fields !== void 0 && _node$fields.slug ? (_node$fields$slug = node.fields.slug) === null || _node$fields$slug === void 0 ? void 0 : _node$fields$slug.replace(/^\/|\/$/, "") : node === null || node === void 0 ? void 0 : (_node$slug = node.slug) === null || _node$slug === void 0 ? void 0 : _node$slug.replace(/^\/|\/$/, ""); | ||
if (!slug) { | ||
return false; | ||
} | ||
excludedRoute = typeof excludedRoute === "object" ? excludedRoute : excludedRoute.replace(/^\/|\/$/, ""); // test if the passed regular expression is valid | ||
@@ -133,3 +136,4 @@ | ||
return r.data; | ||
var newData = r.data; | ||
return newData; | ||
}); | ||
@@ -194,3 +198,2 @@ }; | ||
node = (0, _helpers.getNodePath)(node, allSitePagePathNodeMap); | ||
sourceObject[mapping[type].sitemap].push({ | ||
@@ -197,0 +200,0 @@ url: new URL(node.path, siteURL).toString(), |
{ | ||
"name": "gatsby-plugin-advanced-sitemap-patch", | ||
"description": "Advanced plugin for generating configurable XML sitemaps with linked media for better SEO and human-readable XSL templates.", | ||
"version": "2.1.4", | ||
"version": "2.1.5", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "author": "Ghost Foundation", |
@@ -20,3 +20,2 @@ import path from "path"; | ||
} from "./serializers"; | ||
import { getNodePath } from "./helpers"; | ||
@@ -58,3 +57,4 @@ let siteURL; | ||
const serializedEdges = mapping[source].serializer( | ||
r.data[source].edges | ||
r.data[source].edges, | ||
r.data | ||
); | ||
@@ -72,7 +72,11 @@ | ||
// Removing excluded paths | ||
if (r.data?.[source]?.edges && r.data[source].edges.length) { | ||
if ( | ||
r.data?.[source]?.edges && | ||
r.data[source].edges.length && | ||
source !== "site" | ||
) { | ||
r.data[source].edges = r.data[source].edges.filter( | ||
({ node }) => | ||
!exclude.some((excludedRoute) => { | ||
const sourceType = node.__typename | ||
const sourceType = node?.__typename | ||
? `all${node.__typename}` | ||
@@ -84,5 +88,7 @@ : source; | ||
node?.fields?.slug | ||
? node.fields.slug.replace(/^\/|\/$/, ``) | ||
: node.slug.replace(/^\/|\/$/, ``); | ||
? node.fields.slug?.replace(/^\/|\/$/, ``) | ||
: node?.slug?.replace(/^\/|\/$/, ``); | ||
if (!slug) { | ||
return false; | ||
} | ||
excludedRoute = | ||
@@ -117,4 +123,5 @@ typeof excludedRoute === `object` | ||
} | ||
let newData = r.data; | ||
return r.data; | ||
return newData; | ||
}); | ||
@@ -179,3 +186,2 @@ | ||
// get the real path for the node, which is generated by Gatsby | ||
node = getNodePath(node, allSitePagePathNodeMap); | ||
@@ -182,0 +188,0 @@ sourceObject[mapping[type].sitemap].push({ |
92397
1764