diff --git a/gatsby-config.js b/gatsby-config.js index 9fa59236..807b8eab 100644 --- a/gatsby-config.js +++ b/gatsby-config.js @@ -1,3 +1,8 @@ +const webflowPosts = require("./src/blog-details") + +const ignorePaths = ['/','/404'] + + module.exports = { siteMetadata: { title: `SuperTokens Blog`, @@ -72,6 +77,51 @@ module.exports = { }, `gatsby-transformer-sharp`, `gatsby-plugin-sharp`, + { + resolve: "gatsby-plugin-sitemap", + options: { + query:` + { + allSitePage { + nodes { + path + } + } + } + `, + output:'/sitemaps', + resolveSiteUrl: () => 'https://supertokens.com/', + resolvePages: ({ + allSitePage: { nodes:allPages } + }) => { + const webflowBlogsWithTrailingSlashes = webflowPosts.reduce((acc,currentPage)=>{ + + if(currentPage.fields.slug === undefined){ + return acc + } + + return [...acc , {path: `blog${currentPage.fields.slug}`}, {path:`blog${currentPage.fields.slug}/`}]; + },[]) + + const allPagesWithTralingSlashes = allPages.reduce((acc,currentPage)=>{ + + if(ignorePaths.includes(currentPage.path)){ + return acc; + } + + const pathWithTrailingSlash = { path: currentPage.path + '/' } + return [...acc, currentPage, pathWithTrailingSlash] + },[]) + + return [...allPagesWithTralingSlashes, ...webflowBlogsWithTrailingSlashes]; + }, + serialize: ({ path }) => { + return { + url: path, + } + }, + }, + }, // { // resolve: `gatsby-plugin-google-analytics`, // options: { diff --git a/package-lock.json b/package-lock.json index 05b7519e..3ec4e37c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "gatsby-plugin-gatsby-cloud": "^4.7.0", "gatsby-plugin-image": "^2.7.0", "gatsby-plugin-sharp": "^4.7.0", + "gatsby-plugin-sitemap": "^6.12.0", "gatsby-remark-autolink-headers": "^5.22.0", "gatsby-remark-copy-linked-files": "^5.7.0", "gatsby-remark-external-links": "^0.0.4", @@ -1638,11 +1639,11 @@ } }, "node_modules/@babel/runtime": { - "version": "7.17.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.2.tgz", - "integrity": "sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.15.tgz", + "integrity": "sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==", "dependencies": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.14.0" }, "engines": { "node": ">=6.9.0" @@ -1660,6 +1661,11 @@ "node": ">=6.9.0" } }, + "node_modules/@babel/runtime/node_modules/regenerator-runtime": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", + "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==" + }, "node_modules/@babel/template": { "version": "7.16.7", "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.16.7.tgz", @@ -3008,6 +3014,14 @@ "@types/node": "*" } }, + "node_modules/@types/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw==", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/scheduler": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", @@ -8850,6 +8864,25 @@ "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, + "node_modules/gatsby-plugin-sitemap": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/gatsby-plugin-sitemap/-/gatsby-plugin-sitemap-6.12.0.tgz", + "integrity": "sha512-wD8c++ubDOdYHND+w1nAkdpNGc9Tb0VLZua8PeVSSAFgqgQzgm+LXfuW2yg5wNUOkYG9Qc9HlkORg+oyzk3xTQ==", + "dependencies": { + "@babel/runtime": "^7.20.13", + "common-tags": "^1.8.2", + "minimatch": "^3.1.2", + "sitemap": "^7.1.1" + }, + "engines": { + "node": ">=18.0.0" + }, + "peerDependencies": { + "gatsby": "^5.0.0-next", + "react": "^18.0.0 || ^0.0.0", + "react-dom": "^18.0.0 || ^0.0.0" + } + }, "node_modules/gatsby-plugin-typescript": { "version": "4.9.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-4.9.0.tgz", @@ -16602,6 +16635,29 @@ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" }, + "node_modules/sitemap": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/sitemap/-/sitemap-7.1.1.tgz", + "integrity": "sha512-mK3aFtjz4VdJN0igpIJrinf3EO8U8mxOPsTBzSsy06UtjZQJ3YY3o3Xa7zSc5nMqcMrRwlChHZ18Kxg0caiPBg==", + "dependencies": { + "@types/node": "^17.0.5", + "@types/sax": "^1.2.1", + "arg": "^5.0.0", + "sax": "^1.2.4" + }, + "bin": { + "sitemap": "dist/cli.js" + }, + "engines": { + "node": ">=12.0.0", + "npm": ">=5.6.0" + } + }, + "node_modules/sitemap/node_modules/arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==" + }, "node_modules/slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", @@ -20712,11 +20768,18 @@ } }, "@babel/runtime": { - "version": "7.17.2", - "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.17.2.tgz", - "integrity": "sha512-hzeyJyMA1YGdJTuWU0e/j4wKXrU4OMFvY2MSlaI9B7VQb0r5cxTE3EAIS2Q7Tn2RIcDkRvTA/v2JsAEhxe99uw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.22.15.tgz", + "integrity": "sha512-T0O+aa+4w0u06iNmapipJXMV4HoUir03hpx3/YqXXhu9xim3w+dVphjFWl1OH8NbZHw5Lbm9k45drDkgq2VNNA==", "requires": { - "regenerator-runtime": "^0.13.4" + "regenerator-runtime": "^0.14.0" + }, + "dependencies": { + "regenerator-runtime": { + "version": "0.14.0", + "resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz", + "integrity": "sha512-srw17NI0TUWHuGa5CFGGmhfNIeja30WMBfbslPNhf6JrqQlLN5gcrvig1oqPxiVaXb0oW0XRKtH6Nngs5lKCIA==" + } } }, "@babel/runtime-corejs3": { @@ -21832,6 +21895,14 @@ "@types/node": "*" } }, + "@types/sax": { + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/@types/sax/-/sax-1.2.4.tgz", + "integrity": "sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw==", + "requires": { + "@types/node": "*" + } + }, "@types/scheduler": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/@types/scheduler/-/scheduler-0.16.2.tgz", @@ -26345,6 +26416,17 @@ } } }, + "gatsby-plugin-sitemap": { + "version": "6.12.0", + "resolved": "https://registry.npmjs.org/gatsby-plugin-sitemap/-/gatsby-plugin-sitemap-6.12.0.tgz", + "integrity": "sha512-wD8c++ubDOdYHND+w1nAkdpNGc9Tb0VLZua8PeVSSAFgqgQzgm+LXfuW2yg5wNUOkYG9Qc9HlkORg+oyzk3xTQ==", + "requires": { + "@babel/runtime": "^7.20.13", + "common-tags": "^1.8.2", + "minimatch": "^3.1.2", + "sitemap": "^7.1.1" + } + }, "gatsby-plugin-typescript": { "version": "4.9.0", "resolved": "https://registry.npmjs.org/gatsby-plugin-typescript/-/gatsby-plugin-typescript-4.9.0.tgz", @@ -31952,6 +32034,24 @@ "resolved": "https://registry.npmjs.org/sisteransi/-/sisteransi-1.0.5.tgz", "integrity": "sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==" }, + "sitemap": { + "version": "7.1.1", + "resolved": "https://registry.npmjs.org/sitemap/-/sitemap-7.1.1.tgz", + "integrity": "sha512-mK3aFtjz4VdJN0igpIJrinf3EO8U8mxOPsTBzSsy06UtjZQJ3YY3o3Xa7zSc5nMqcMrRwlChHZ18Kxg0caiPBg==", + "requires": { + "@types/node": "^17.0.5", + "@types/sax": "^1.2.1", + "arg": "^5.0.0", + "sax": "^1.2.4" + }, + "dependencies": { + "arg": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/arg/-/arg-5.0.2.tgz", + "integrity": "sha512-PYjyFOLKQ9y57JvQ6QLo8dAgNqswh8M1RMJYdQduT6xbWSgK36P/Z/v+p888pM69jMMfS8Xd8F6I1kQ/I9HUGg==" + } + } + }, "slash": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-3.0.0.tgz", diff --git a/package.json b/package.json index e002363c..6e488241 100644 --- a/package.json +++ b/package.json @@ -10,6 +10,7 @@ "gatsby-plugin-gatsby-cloud": "^4.7.0", "gatsby-plugin-image": "^2.7.0", "gatsby-plugin-sharp": "^4.7.0", + "gatsby-plugin-sitemap": "^6.12.0", "gatsby-remark-autolink-headers": "^5.22.0", "gatsby-remark-copy-linked-files": "^5.7.0", "gatsby-remark-external-links": "^0.0.4",