Skip to content

Commit e8036f3

Browse files
committed
Feat: Add RSS
Feat: Add sitemap
1 parent 7981c76 commit e8036f3

File tree

5 files changed

+359
-4
lines changed

5 files changed

+359
-4
lines changed

gatsby-config.js

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
*
44
* See: https://www.gatsbyjs.com/docs/reference/config-files/gatsby-config/
55
*/
6+
const siteUrl = `https://blog.micropasts.org`
67

78
/**
89
* @type {import('gatsby').GatsbyConfig}
@@ -137,6 +138,35 @@ module.exports = {
137138
}
138139
}
139140
},
141+
{
142+
resolve: "gatsby-plugin-sitemap",
143+
options: {
144+
query: `
145+
{
146+
allSitePage {
147+
nodes {
148+
path
149+
}
150+
}
151+
152+
}
153+
`,
154+
resolveSiteUrl: () => siteUrl,
155+
resolvePages: ({
156+
allSitePage: { nodes: allPages }
157+
}) => {
158+
159+
return allPages.map(page => {
160+
return { ...page };
161+
});
162+
},
163+
serialize: ({ path }) => {
164+
return {
165+
url: path
166+
};
167+
}
168+
}
169+
},
140170
{
141171
resolve: `gatsby-plugin-google-gtag`,
142172
options: {
@@ -148,6 +178,57 @@ module.exports = {
148178
},
149179
},
150180
},
181+
{
182+
resolve: `gatsby-plugin-feed`,
183+
options: {
184+
query: `
185+
{
186+
site {
187+
siteMetadata {
188+
title
189+
description
190+
siteUrl
191+
site_url: siteUrl
192+
}
193+
}
194+
}
195+
`,
196+
feeds: [
197+
{
198+
serialize: ({ query: { site, allMarkdownRemark } }) => {
199+
return allMarkdownRemark.nodes.map(node => {
200+
return Object.assign({}, node.frontmatter, {
201+
description: node.excerpt,
202+
date: node.frontmatter.date,
203+
url: site.siteMetadata.siteUrl + node.frontmatter.permalink,
204+
guid: site.siteMetadata.siteUrl + node.frontmatter.permalink,
205+
custom_elements: [{ "content:encoded": node.html }],
206+
})
207+
})
208+
},
209+
query: `
210+
{
211+
allMarkdownRemark(
212+
sort: { order: DESC, fields: [frontmatter___date] },
213+
) {
214+
nodes {
215+
excerpt
216+
html
217+
frontmatter {
218+
title
219+
date
220+
permalink
221+
}
222+
}
223+
}
224+
}
225+
`,
226+
output: "/rss.xml",
227+
title: "MicroPasts Blog RSS Feed"
228+
},
229+
],
230+
},
231+
},
151232
{
152233
resolve: `gatsby-plugin-manifest`,
153234
options: {

0 commit comments

Comments
 (0)