Open willashiomos opened 1 year ago
Hi! 👋
Today I used patch-package to patch gatsby-plugin-yoast-sitemap@0.0.2 for the project I'm working on.
gatsby-plugin-yoast-sitemap@0.0.2
Here is the diff that solved my problem:
diff --git a/node_modules/gatsby-plugin-yoast-sitemap/gatsby-node.js b/node_modules/gatsby-plugin-yoast-sitemap/gatsby-node.js index 2cabc13..7f0416b 100644 --- a/node_modules/gatsby-plugin-yoast-sitemap/gatsby-node.js +++ b/node_modules/gatsby-plugin-yoast-sitemap/gatsby-node.js @@ -41,7 +41,7 @@ exports.createPages = async ({ actions, graphql }, options) => { const xslFile = await axios.get(`https://${xslUrl}`, { auth: auth }); await fse.outputFile(path.join(publicPath, `sitemap.xsl`), xslFile.data); - const downloadableXMLNodes = await extractUrls(siteMapIndex.data); + const downloadableXMLNodes = await extractUrls(siteMapIndex.data, auth); siteMapIndex = siteMapIndex.data.replaceAll( xslUrl, `${gatsbyUrl}/sitemap.xsl` diff --git a/node_modules/gatsby-plugin-yoast-sitemap/parse-sitemap.js b/node_modules/gatsby-plugin-yoast-sitemap/parse-sitemap.js index 30b5dc5..5626868 100644 --- a/node_modules/gatsby-plugin-yoast-sitemap/parse-sitemap.js +++ b/node_modules/gatsby-plugin-yoast-sitemap/parse-sitemap.js @@ -3,17 +3,17 @@ const axios = require("axios"); const urls = []; -async function extractSingleUrl(url) { +async function extractSingleUrl(url, auth) { if (url.slice(-4) === ".xml" || url.slice(-4) === ".kml") { urls.push(url); if (url.search(/\.xml$/)) { - const siteMapIndex = await axios.get(url); + const siteMapIndex = await axios.get(url, { auth: auth }); await walkUrls(siteMapIndex.data); } } } -async function walkUrls(xml, url) { +async function walkUrls(xml, auth, url) { const $ = cheerio.load(xml, { xmlMode: true }); const locs = []; @@ -28,12 +28,12 @@ async function walkUrls(xml, url) { }); for (const loc of locs) { - await extractSingleUrl(loc); + await extractSingleUrl(loc, auth); } } -async function extractUrls(xml, cliFlags) { - const result = await walkUrls(xml); +async function extractUrls(xml, auth, cliFlags) { + const result = await walkUrls(xml, auth); console.log(result); return urls;
Hi! 👋
Today I used patch-package to patch
gatsby-plugin-yoast-sitemap@0.0.2
for the project I'm working on.Here is the diff that solved my problem: