forked from gatsbyjs/gatsby
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
created gatsby-plugin-feed default for mdx (gatsbyjs#137)
- Loading branch information
1 parent
095442d
commit fd99b9e
Showing
1 changed file
with
65 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` | ||
} | ||
] | ||
}; |