Merge pull request #1544 from SkynetLabs/website-sitemap

add sitemap generation
This commit is contained in:
Karol Wypchło 2022-01-13 13:11:16 +01:00 committed by GitHub
commit 3e89b5b2ff
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 103 additions and 1 deletions

View File

@ -117,6 +117,75 @@ module.exports = {
siteUrl: "https://siasky.net",
},
},
{
resolve: "gatsby-plugin-sitemap",
options: {
output: "/",
createLinkInHead: true,
excludes: ["/using-typescript/"],
query: `
{
site {
siteMetadata {
siteUrl
}
}
allSitePage {
nodes {
path
}
}
allMarkdownRemark {
nodes {
frontmatter {
date,
hidden
},
fields {
slug
}
}
}
}
`,
resolvePages: ({ allSitePage: { nodes: allPages }, allMarkdownRemark: { nodes: allNews } }) => {
const pathToDateMap = {};
allNews.map((post) => {
pathToDateMap[post.fields.slug] = { date: post.frontmatter.date, hidden: post.frontmatter.hidden };
});
// modify pages to filter out hidden news items and add date
const pages = allPages
.filter((page) => {
if (pathToDateMap[page.path] && pathToDateMap[page.path].hidden) {
return false;
}
return true;
})
.map((page) => {
return { ...page, ...pathToDateMap[page.path] };
});
return pages;
},
serialize: ({ path, date }) => {
let entry = {
url: path,
changefreq: "daily",
priority: 0.5,
};
if (date) {
entry.priority = 0.7;
entry.lastmod = date;
}
return entry;
},
},
},
],
// mapping: {
// "MarkdownRemark.frontmatter.author": `teamYaml`,

View File

@ -25,6 +25,7 @@
"gatsby-plugin-react-helmet": "5.4.0",
"gatsby-plugin-robots-txt": "1.6.14",
"gatsby-plugin-sharp": "4.4.0",
"gatsby-plugin-sitemap": "5.5.0",
"gatsby-plugin-svgr": "3.0.0-beta.0",
"gatsby-remark-classes": "1.0.2",
"gatsby-remark-copy-linked-files": "5.4.0",

View File

@ -2137,6 +2137,11 @@
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.18.0.tgz#98df2397f6936bfbff4f089e40e06fa5dd88d32a"
integrity sha512-0GeIl2kmVMXEnx8tg1SlG6Gg8vkqirrW752KqolYo1PHevhhZN3bhJ67qHj+bQaINhX0Ra3TlWwRvMCd9iEfNQ==
"@types/node@^17.0.5":
version "17.0.8"
resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.8.tgz#50d680c8a8a78fe30abe6906453b21ad8ab0ad7b"
integrity sha512-YofkM6fGv4gDJq78g4j0mMuGMkZVxZDgtU0JRdx6FgiJDG+0fY0GKVolOV8WqVmEhLCXkQRjwDdKyPxJp/uucg==
"@types/node@^8.5.7":
version "8.10.66"
resolved "https://registry.yarnpkg.com/@types/node/-/node-8.10.66.tgz#dd035d409df322acc83dff62a602f12a5783bbb3"
@ -2198,6 +2203,13 @@
"@types/glob" "*"
"@types/node" "*"
"@types/sax@^1.2.1":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@types/sax/-/sax-1.2.4.tgz#8221affa7f4f3cb21abd22f244cfabfa63e6a69e"
integrity sha512-pSAff4IAxJjfAXUG6tFkO7dsSbTmf8CtUpfhhZ5VhkRpC4628tJhh3+V6H1E+/Gs9piSzYKT5yzHO5M4GG9jkw==
dependencies:
"@types/node" "*"
"@types/scheduler@*":
version "0.16.2"
resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"
@ -2666,7 +2678,7 @@ arg@^4.1.0:
resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089"
integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA==
arg@^5.0.1:
arg@^5.0.0, arg@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.1.tgz#eb0c9a8f77786cad2af8ff2b862899842d7b6adb"
integrity sha512-e0hDa9H2Z9AwFkk2qDlwhoMYE4eToKarchkQHovNdLTCYMHZHeRjI71crOh+dio4K6u1IcwubQqo79Ga4CyAQA==
@ -6218,6 +6230,16 @@ gatsby-plugin-sharp@4.4.0:
svgo "1.3.2"
uuid "3.4.0"
gatsby-plugin-sitemap@5.5.0:
version "5.5.0"
resolved "https://registry.yarnpkg.com/gatsby-plugin-sitemap/-/gatsby-plugin-sitemap-5.5.0.tgz#d82bb8454711ffad2747cb2ed8d6e8e184b7ffa7"
integrity sha512-M98bxeJ6O4fPeefc35nv9q44D2RREdpnhPf0q6pDIJuGhXtdwXesSCCi6/4hZOUfOHyOYwxoKPlE7p7zx4SqWw==
dependencies:
"@babel/runtime" "^7.15.4"
common-tags "^1.8.2"
minimatch "^3.0.4"
sitemap "^7.0.0"
gatsby-plugin-svgr@3.0.0-beta.0:
version "3.0.0-beta.0"
resolved "https://registry.yarnpkg.com/gatsby-plugin-svgr/-/gatsby-plugin-svgr-3.0.0-beta.0.tgz#7e5315f51dae2663a447899322ea1487cef93dd6"
@ -11884,6 +11906,16 @@ sisteransi@^1.0.5:
resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-1.0.5.tgz#134d681297756437cc05ca01370d3a7a571075ed"
integrity sha512-bLGGlR1QxBcynn2d5YmDX4MGjlZvy2MRBDRNHLJ8VI6l6+9FUiyTFNJ0IveOSP0bcXgVDPRcfGqA0pjaqUpfVg==
sitemap@^7.0.0:
version "7.1.0"
resolved "https://registry.yarnpkg.com/sitemap/-/sitemap-7.1.0.tgz#300cd8b3fa9d45fb63f9b56d962785c3cd799362"
integrity sha512-OctwI2RYFj3Lnoutix0Qhow3AvDoUQ7rsSyzrY8wFKHqXYvmCJXFOBZyVU4/DDtsQ2KnEWY4j4j80hBHBOVEWQ==
dependencies:
"@types/node" "^17.0.5"
"@types/sax" "^1.2.1"
arg "^5.0.0"
sax "^1.2.4"
sjcl@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/sjcl/-/sjcl-1.0.8.tgz#f2ec8d7dc1f0f21b069b8914a41a8f236b0e252a"