From f53feb361ce1e60cf3b6acc8e64f3ca06a84cf74 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Sun, 13 Nov 2022 04:07:17 +0000 Subject: [PATCH] feat: support for Gatsby v5 (#679) * feat: support for Gatsby v5 * ci: run checks on pull request, not on target --- .github/workflows/dev.yml | 4 ++-- package.json | 2 +- src/gatsby-node.js | 2 +- test/__snapshots__/gatsby-node.test.js.snap | 2 +- test/gatsby-node.test.js | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 6437f78..a0e92ee 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,7 +3,7 @@ on: push: branches: - main - pull_request_target: + pull_request: branches: - main jobs: @@ -12,7 +12,7 @@ jobs: strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] - node: ["14.x"] + node: ["18.x"] steps: - name: Setup uses: actions/setup-node@v3.1.1 diff --git a/package.json b/package.json index cc3f385..7c51512 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,7 @@ "semantic-release": "^19.0.2" }, "peerDependencies": { - "gatsby": "^4.0.0 || ^3.0.0 || ^2.0.0" + "gatsby": "^5.0.0" }, "jest": { "collectCoverage": true diff --git a/src/gatsby-node.js b/src/gatsby-node.js index d0d8945..6e1962f 100644 --- a/src/gatsby-node.js +++ b/src/gatsby-node.js @@ -63,7 +63,7 @@ export async function onPostBuild({ graphql, pathPrefix = "" }, pluginOptions) { !Object.prototype.hasOwnProperty.call(mergedOptions, 'sitemap') ) { - mergedOptions.sitemap = new URL(path.posix.join(pathPrefix, 'sitemap', 'sitemap-index.xml'), mergedOptions.host).toString(); + mergedOptions.sitemap = new URL(path.posix.join(pathPrefix, 'sitemap-index.xml'), mergedOptions.host).toString(); } else { try { new URL(mergedOptions.sitemap) diff --git a/test/__snapshots__/gatsby-node.test.js.snap b/test/__snapshots__/gatsby-node.test.js.snap index ed8c692..61eb746 100644 --- a/test/__snapshots__/gatsby-node.test.js.snap +++ b/test/__snapshots__/gatsby-node.test.js.snap @@ -19,7 +19,7 @@ Host: https://www.test.com exports[`onPostBuild should generate \`robots.txt\` using \`graphql\` options 1`] = ` "User-agent: * Allow: / -Sitemap: https://www.test.com/sitemap/sitemap-index.xml +Sitemap: https://www.test.com/sitemap-index.xml Host: https://www.test.com " `; diff --git a/test/gatsby-node.test.js b/test/gatsby-node.test.js index f9984c2..94bc787 100644 --- a/test/gatsby-node.test.js +++ b/test/gatsby-node.test.js @@ -264,7 +264,7 @@ describe('onPostBuild', () => { const data = await fsp.readFile(resolvePath(output)) - expect(data.toString()).toContain('Sitemap: https://www.test.com/prefix/sitemap/sitemap-index.xml'); + expect(data.toString()).toContain('Sitemap: https://www.test.com/prefix/sitemap-index.xml'); }) it(`should add pathPrefix to provided sitemap`, async () => {