Skip to content

Commit

Permalink
created gatsby-plugin-feed default for mdx (gatsbyjs#137)
Browse files Browse the repository at this point in the history
  • Loading branch information
avigoldman authored and ChristopherBiscardi committed Jun 27, 2019
1 parent 095442d commit fd99b9e
Showing 1 changed file with 65 additions and 0 deletions.
65 changes: 65 additions & 0 deletions packages/gatsby-plugin-mdx/feed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/**
* Configuration for `gatsby-plugin-feed` equivalent to the default, but for MDX
* instead of remark.
*
* Original default: https://github.com/gatsbyjs/gatsby/blob/master/packages/gatsby-plugin-feed/src/internals.js#L20
* Usage: gatsby-config.js
*
* ```
* const mdxFeed = require("gatsby-mdx/feed");
*
* module.exports = {
* plugins: [
* {
* resolve: `gatsby-plugin-feed`,
* options: mdxFeed
* }
* ]
* };
* ```
*
*/
module.exports = {
/**
* no need to specify the other options, since they will be merged with this
*/
feeds: [
{
serialize: ({ query: { site, allMdx } }) => {
return allMdx.edges.map(edge => {
return {
...edge.node.frontmatter,
description: edge.node.excerpt,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + edge.node.fields.slug
};
});
},
query: `
{
allMdx(
limit: 1000,
sort: {
order: DESC,
fields: [frontmatter___date]
}
) {
edges {
node {
frontmatter {
title
date
}
fields {
slug
}
excerpt
}
}
}
}
`,
output: `rss.xml`
}
]
};

0 comments on commit fd99b9e

Please sign in to comment.