Skip to content

Commit

Permalink
Add RSS feed plugin
Browse files Browse the repository at this point in the history
Signed-off-by: Nikhil-Ladha <[email protected]>
  • Loading branch information
Nikhil-Ladha committed Mar 12, 2021
1 parent d051430 commit 57c1f4f
Show file tree
Hide file tree
Showing 3 changed files with 217 additions and 28 deletions.
59 changes: 59 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,65 @@ module.exports = {
},
},
},
{
resolve: "gatsby-plugin-feed",
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allPosts }}) => {
return allPosts.nodes.map( node => {
return Object.assign({}, node.frontmatter, {
title: node.frontmatter.title,
author: node.frontmatter.author,
description: node.excerpt,
date: node.frontmatter.date,
url: site.siteMetadata.siteUrl + node.fields.slug,
guid: site.siteMetadata.siteUrl + node.fields.slug,
// custom_elements: [{ "content:encoded": node.html }],
});
});
},
query: `
{
allPosts: allMdx(
sort: { fields: [frontmatter___date], order: DESC }
filter: { fields: { collection: { eq: "blog" } }, frontmatter: { published: { eq: true } } }
limit: 8
) {
nodes {
body
frontmatter {
title
author
date(formatString: "MMMM Do, YYYY")
thumbnail{
publicURL
}
}
fields {
slug
}
}
}
}
`,
output: "/rss.xml",
},
],
},
},
{
resolve: "gatsby-plugin-styled-components",
options: {
Expand Down
Loading

0 comments on commit 57c1f4f

Please sign in to comment.