Skip to content

Commit

Permalink
add RSS feed
Browse files Browse the repository at this point in the history
  • Loading branch information
LekoArts committed Nov 16, 2019
1 parent 17adc0c commit 268ad29
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 2 deletions.
2 changes: 2 additions & 0 deletions themes/gatsby-theme-minimal-blog-core/gatsby-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ exports.createSchemaCustomization = ({ actions, schema }, themeOptions) => {
date: Date! @dateformat
excerpt(pruneLength: Int = 160): String!
body: String!
html: String
timeToRead: Int!
tags: [PostTag]
banner: File @fileByRelativePath
Expand All @@ -100,6 +101,7 @@ exports.createSchemaCustomization = ({ actions, schema }, themeOptions) => {
date: Date! @dateformat
excerpt(pruneLength: Int = 140): String! @mdxpassthrough(fieldName: "excerpt")
body: String! @mdxpassthrough(fieldName: "body")
html: String! @mdxpassthrough(fieldName: "html")
timeToRead: Int! @mdxpassthrough(fieldName: "timeToRead")
tags: [PostTag]
banner: File @fileByRelativePath
Expand Down
6 changes: 6 additions & 0 deletions themes/gatsby-theme-minimal-blog/gatsby-config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const newsletterFeed = require(`./src/utils/newsletterFeed`)

module.exports = options => {
const showLineNumbers = options.showLineNumbers || true

Expand Down Expand Up @@ -34,6 +36,10 @@ module.exports = options => {
resolve: `@lekoarts/gatsby-theme-minimal-blog-core`,
options,
},
{
resolve: `gatsby-plugin-feed`,
options: newsletterFeed,
},
`gatsby-plugin-react-helmet`,
`gatsby-plugin-typescript`,
`gatsby-plugin-catch-links`,
Expand Down
1 change: 1 addition & 0 deletions themes/gatsby-theme-minimal-blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"@theme-ui/components": "^0.2.46",
"@theme-ui/presets": "^0.2.15",
"gatsby-plugin-catch-links": "^2.1.15",
"gatsby-plugin-feed": "^2.3.21",
"gatsby-plugin-react-helmet": "^3.1.13",
"gatsby-plugin-theme-ui": "^0.2.18",
"gatsby-plugin-typescript": "^2.1.2",
Expand Down
46 changes: 46 additions & 0 deletions themes/gatsby-theme-minimal-blog/src/utils/newsletterFeed.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/* eslint arrow-body-style: 0 */

module.exports = {
query: `
{
site {
siteMetadata {
title: siteTitle
description: siteDescription
siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allPost } }) => {
return allPost.nodes.map(post => {
return {
title: post.title,
date: post.date,
excerpt: post.excerpt,
url: site.siteMetadata.siteUrl + post.slug,
guid: site.siteMetadata.siteUrl + post.slug,
custom_elements: [{ "content:encoded": post.html }],
}
})
},
query: `
{
allPost(sort: { fields: date, order: DESC }) {
nodes {
title
date(formatString: "MMMM D, YYYY")
excerpt
slug
html
}
}
}
`,
output: `rss.xml`,
title: `Minimal Blog - @lekoarts/gatsby-theme-minimal-blog`,
},
],
}
35 changes: 33 additions & 2 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8421,6 +8421,17 @@ gatsby-plugin-emotion@^4.1.3:
"@babel/runtime" "^7.6.3"
"@emotion/babel-preset-css-prop" "^10.0.22"

gatsby-plugin-feed@^2.3.21:
version "2.3.21"
resolved "https://registry.yarnpkg.com/gatsby-plugin-feed/-/gatsby-plugin-feed-2.3.21.tgz#b26d05d75427c037421344b62ad728b7fe0efa97"
integrity sha512-v9zz3JPdU7+hxtRUMP+OfC6fagkUpU6rW61XptdCi2cC8GCHp+YIs3FFRCYQmsOMPKqbIWfUyyR6Mljzu8Giew==
dependencies:
"@babel/runtime" "^7.7.2"
"@hapi/joi" "^15.1.1"
fs-extra "^8.1.0"
lodash.merge "^4.6.2"
rss "^1.2.2"

gatsby-plugin-google-analytics@^2.1.13, gatsby-plugin-google-analytics@^2.1.4, gatsby-plugin-google-analytics@^2.1.8:
version "2.1.24"
resolved "https://registry.yarnpkg.com/gatsby-plugin-google-analytics/-/gatsby-plugin-google-analytics-2.1.24.tgz#ab1aa59503d236d61873a1b14205976d89ddabb3"
Expand Down Expand Up @@ -11935,7 +11946,7 @@ lodash.memoize@4.x, lodash.memoize@^4.1.2:
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
integrity sha1-vMbEmkKihA7Zl/Mj6tpezRguC/4=

lodash.merge@^4.4.0:
lodash.merge@^4.4.0, lodash.merge@^4.6.2:
version "4.6.2"
resolved "https://registry.yarnpkg.com/lodash.merge/-/lodash.merge-4.6.2.tgz#558aa53b43b661e1925a0afdfa36a9a1085fe57a"
integrity sha512-0KpjqXRVvrYyCsX1swR/XTK0va6VQkQM6MNo7PqW77ByjAhoARA8EfrP1N4+KlKj8YS0ZUCtRT/YUuhyYDujIQ==
Expand Down Expand Up @@ -12560,6 +12571,18 @@ mime-db@1.40.0:
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.42.0.tgz#3e252907b4c7adb906597b4b65636272cf9e7bac"
integrity sha512-UbfJCR4UAVRNgMpfImz05smAXK7+c+ZntjaA26ANtkXLlOe947Aag5zdIcKQULAiF9Cq4WxBi9jUs5zkA84bYQ==

mime-db@~1.25.0:
version "1.25.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392"
integrity sha1-wY29fHOl2/b0SgJNwNFloeexw5I=

mime-types@2.1.13:
version "2.1.13"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88"
integrity sha1-4HqqnGxrmnyjASxpADrSWjnpKog=
dependencies:
mime-db "~1.25.0"

mime-types@^2.0.1, mime-types@^2.1.12, mime-types@~2.1.17, mime-types@~2.1.19, mime-types@~2.1.24:
version "2.1.24"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.24.tgz#b6f8d0b3e951efb77dedeca194cff6d16f676f81"
Expand Down Expand Up @@ -16045,6 +16068,14 @@ ripemd160@^2.0.0, ripemd160@^2.0.1:
hash-base "^3.0.0"
inherits "^2.0.1"

rss@^1.2.2:
version "1.2.2"
resolved "https://registry.yarnpkg.com/rss/-/rss-1.2.2.tgz#50a1698876138133a74f9a05d2bdc8db8d27a921"
integrity sha1-UKFpiHYTgTOnT5oF0r3I240nqSE=
dependencies:
mime-types "2.1.13"
xml "1.0.1"

rsvp@^4.8.4:
version "4.8.5"
resolved "https://registry.yarnpkg.com/rsvp/-/rsvp-4.8.5.tgz#c8f155311d167f68f21e168df71ec5b083113734"
Expand Down Expand Up @@ -19245,7 +19276,7 @@ xml2js@^0.4.5:
util.promisify "~1.0.0"
xmlbuilder "~11.0.0"

xml@^1.0.1:
xml@1.0.1, xml@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"
integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU=
Expand Down

0 comments on commit 268ad29

Please sign in to comment.