mirror of
https://github.com/kremalicious/blog.git
synced 2025-01-03 10:25:07 +01:00
add rss feed
This commit is contained in:
parent
4316a09a70
commit
8dce8c4df4
@ -11,7 +11,7 @@ install:
|
||||
|
||||
script:
|
||||
- npm test
|
||||
- travis_wait 30 npm run build
|
||||
- npm run build
|
||||
|
||||
after_success:
|
||||
- pip install --user awscli
|
||||
|
@ -20,8 +20,8 @@ author:
|
||||
github: https://github.com/kremalicious
|
||||
facebook: https://facebook.com/matthiaskretschmann
|
||||
googleplus: https://plus.google.com/+MatthiasKretschmann
|
||||
rss: https://kremalicious.com/feed.xml
|
||||
jsonfeed: http://kremalicious.com/feed.json
|
||||
rss: /feed.xml
|
||||
jsonfeed: /feed.json
|
||||
avatar: ../src/images/avatar.jpg
|
||||
bitcoin: 171qDmKEXm9YBgBLXyGjjPvopP5o9htQ1V
|
||||
ether: "0x339dbC44d39bf1961E385ed0Ae88FC6069b87Ea1"
|
||||
|
@ -2,14 +2,17 @@ const path = require('path')
|
||||
const fs = require('fs')
|
||||
const yaml = require('js-yaml')
|
||||
const meta = yaml.load(fs.readFileSync('./content/meta.yml', 'utf8'))
|
||||
const { url } = meta
|
||||
const { title, tagline, url, author } = meta
|
||||
|
||||
// required for gatsby-plugin-meta-redirect
|
||||
require('regenerator-runtime/runtime')
|
||||
|
||||
module.exports = {
|
||||
siteMetadata: {
|
||||
siteUrl: `${url}`
|
||||
title: `${title}`,
|
||||
description: `${tagline}`,
|
||||
siteUrl: `${url}`,
|
||||
author: `${author.name}`
|
||||
},
|
||||
plugins: [
|
||||
{
|
||||
@ -116,6 +119,64 @@ module.exports = {
|
||||
siteUrl: `${url}`
|
||||
}
|
||||
},
|
||||
{
|
||||
resolve: 'gatsby-plugin-feed',
|
||||
options: {
|
||||
query: `
|
||||
{
|
||||
site {
|
||||
siteMetadata {
|
||||
title
|
||||
description
|
||||
siteUrl
|
||||
site_url: siteUrl
|
||||
author
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
feeds: [
|
||||
{
|
||||
serialize: ({ query: { site, allMarkdownRemark } }) => {
|
||||
return allMarkdownRemark.edges.map(edge => {
|
||||
return Object.assign({}, edge.node.frontmatter, {
|
||||
description: feedContent(edge),
|
||||
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
|
||||
author: site.siteMetadata.author,
|
||||
guid: site.siteMetadata.siteUrl + edge.node.fields.slug
|
||||
})
|
||||
})
|
||||
},
|
||||
query: `
|
||||
{
|
||||
allMarkdownRemark(
|
||||
limit: 20,
|
||||
sort: { order: DESC, fields: [fields___date] }
|
||||
) {
|
||||
edges {
|
||||
node {
|
||||
html
|
||||
fields { slug, date }
|
||||
frontmatter {
|
||||
title
|
||||
image {
|
||||
childImageSharp {
|
||||
resize(width: 960, quality: 80) {
|
||||
src
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`,
|
||||
output: '/feed.xml'
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
'gatsby-plugin-react-helmet',
|
||||
'gatsby-transformer-yaml',
|
||||
'gatsby-plugin-sharp',
|
||||
@ -126,3 +187,11 @@ module.exports = {
|
||||
'gatsby-plugin-meta-redirect'
|
||||
]
|
||||
}
|
||||
|
||||
const feedContent = edge => {
|
||||
const { image } = edge.node.frontmatter
|
||||
|
||||
return image
|
||||
? `<img src="${image.childImageSharp.resize.src}" /><br />${edge.node.html}`
|
||||
: edge.node.html
|
||||
}
|
||||
|
@ -29,6 +29,7 @@
|
||||
"gatsby-awesome-pagination": "^0.1.1",
|
||||
"gatsby-image": "^2.0.0-rc.2",
|
||||
"gatsby-plugin-catch-links": "^2.0.2-rc.1",
|
||||
"gatsby-plugin-feed": "^1.3.25",
|
||||
"gatsby-plugin-lunr": "^1.1.0",
|
||||
"gatsby-plugin-matomo": "^0.5.0",
|
||||
"gatsby-plugin-meta-redirect": "^1.1.0",
|
||||
|
Loading…
Reference in New Issue
Block a user