Skip to content

Commit c41ebdf

Browse files
committed
add rss feed
Signed-off-by: rishichawda <[email protected]>
1 parent 0c44286 commit c41ebdf

File tree

3 files changed

+1589
-1406
lines changed

3 files changed

+1589
-1406
lines changed

gatsby-config.ts

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,63 @@ const config: GatsbyConfig = {
199199
})),
200200
},
201201
},
202+
{
203+
resolve: "gatsby-plugin-feed",
204+
options: {
205+
query: `
206+
{
207+
site {
208+
siteMetadata {
209+
title
210+
description
211+
siteUrl
212+
site_url: siteUrl
213+
}
214+
}
215+
}
216+
`,
217+
feeds: [
218+
{
219+
serialize: ({ query: { site, allMdx } }) => {
220+
return allMdx.edges.map(edge => {
221+
222+
const siteUrl = site.siteMetadata.siteUrl
223+
const slug = siteUrl + edge.node.fields.slug
224+
225+
return Object.assign({}, edge.node.frontmatter, {
226+
url: slug,
227+
guid: slug,
228+
custom_elements: [
229+
{ "content:encoded": edge.node.excerpt }
230+
],
231+
})
232+
})
233+
},
234+
query: `
235+
{
236+
allMdx(sort: {frontmatter: {date: DESC}}) {
237+
edges {
238+
node {
239+
excerpt(pruneLength: 340)
240+
fields {
241+
slug
242+
}
243+
frontmatter {
244+
title
245+
description
246+
date
247+
}
248+
}
249+
}
250+
}
251+
}
252+
`,
253+
output: "/rss.xml",
254+
title: "Rishi's Blog - rishikc.com",
255+
},
256+
]
257+
}
258+
},
202259
"gatsby-plugin-image",
203260
"gatsby-plugin-sharp",
204261
"gatsby-transformer-sharp",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
"gatsby-plugin-canonical-urls": "^5.10.0",
3838
"gatsby-plugin-dark-mode": "^1.1.2",
3939
"gatsby-plugin-disqus": "^1.2.6",
40+
"gatsby-plugin-feed": "^5.11.0",
4041
"gatsby-plugin-image": "^3.10.0",
4142
"gatsby-plugin-local-search": "^2.0.1",
4243
"gatsby-plugin-manifest": "^5.10.0",
@@ -80,4 +81,4 @@
8081
"tailwindcss": "^3.3.2",
8182
"typescript": "^5.0.4"
8283
}
83-
}
84+
}

0 commit comments

Comments
 (0)