Skip to content

Commit

Permalink
add rss feed
Browse files Browse the repository at this point in the history
  • Loading branch information
tuan2311 committed Aug 14, 2020
1 parent f2d94a8 commit e068643
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 0 deletions.
50 changes: 50 additions & 0 deletions gatsby-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -115,5 +115,55 @@ module.exports = {
chunkSize: 10000, // default: 1000
},
},
{
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, docs } }) => {
return docs.nodes.map((node) => {
return Object.assign({}, node.frontmatter, {
description: node.excerpt,
date: node.frontmatter.date,
url: site.siteMetadata.siteUrl + node.slug,
guid: site.siteMetadata.siteUrl + node.slug,
custom_elements: [{ 'content:encoded': node.html }],
});
});
},
query: `
{
docs: allMdx(
sort: { order: DESC, fields: [frontmatter___date] },
) {
nodes {
excerpt
html
slug
frontmatter {
title
date
}
}
}
}
`,
output: '/rss.xml',
title: "Your Site's RSS Feed",
},
],
},
},
],
};
46 changes: 46 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
"eslint-plugin-react": "^7.20.5",
"formik": "^2.1.5",
"gatsby-plugin-emotion": "^4.3.10",
"gatsby-plugin-feed": "^2.5.11",
"gatsby-plugin-layout": "^1.3.10",
"gatsby-plugin-manifest": "^2.4.22",
"gatsby-plugin-netlify-cms": "^4.3.11",
Expand Down

0 comments on commit e068643

Please sign in to comment.