Skip to content
Permalink
Browse files

fix: 🐛 fix rss feed and add link to it to top nav

  • Loading branch information
kitos committed Oct 14, 2019
1 parent 6ed7c12 commit fc4c04a1775c8e83f9d8d0fe8e6b3372ef9fb61b
Showing with 37 additions and 43 deletions.
  1. +12 −5 package-lock.json
  2. +0 −1 package.json
  3. +0 −8 src/components/footer.js
  4. +1 −0 src/components/icons/index.js
  5. +3 −2 src/components/social-links.js
  6. +21 −27 src/gatsby/rss-plugin.js

Some generated files are not rendered by default. Learn more.

@@ -43,7 +43,6 @@
"react-spring": "^7.2.11",
"react-typography": "^0.16.19",
"reason-react": "^0.7.0",
"sanitize-html": "^1.20.1",
"styled-components": "^5.0.0-beta.9",
"typography": "^0.16.19",
"typography-theme-github": "^0.15.10"
@@ -70,14 +70,6 @@ let Footer = () => {
changelog
</BottomLink>

<BottomLink
href={`${meta.siteUrl}/rss.xml`}
target="_blank"
rel="noreferrer noopener"
>
rss
</BottomLink>

<BottomLink
as="button"
onClick={() => openFeedbackDialog({ type: 'feedback' })}
@@ -1,2 +1,3 @@
export * from './github-icon'
export * from './twitter-icon'
export * from './rss-icon'
@@ -3,7 +3,7 @@ import styled from 'styled-components/macro'
import { Flex } from '@rebass/grid'
import VisuallyHidden from '@reach/visually-hidden'

import { FacebookIcon, GitHubIcon, LinkedinIcon, TwitterIcon } from './icons'
import { GitHubIcon, TwitterIcon, RSSIcon } from './icons'

let SocialItem = styled.li`
margin: 0 0 0 8px;
@@ -25,12 +25,13 @@ let SocialItem = styled.li`
let SocialLinks = () => (
<Flex as="ul" m="0" style={{ listStyle: 'none' }}>
{[
{ href: 'https://github.com/kitos', text: 'GitHub', icon: GitHubIcon },
{
href: 'https://twitter.com/kitos_kirsanov',
text: 'Twitter',
icon: TwitterIcon,
},
{ href: 'https://github.com/kitos', text: 'GitHub', icon: GitHubIcon },
{ href: '/blog/rss.xml', text: 'RSS Feads', icon: RSSIcon },
].map(({ href, text, icon: I }) => (
<SocialItem key={href}>
<a href={href} title={text} target="_blank" rel="noreferrer noopener">
@@ -1,14 +1,10 @@
const sanitizeHtml = require('sanitize-html')

let rssPlugin = {
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
}
}
@@ -17,41 +13,39 @@ let rssPlugin = {
feeds: [
{
serialize: ({ query: { site, posts } }) => {
return posts.edges.map(({ node }) => ({
title: node.title,
description: sanitizeHtml(
node.preface.childContentfulRichText.html,
{
allowedTags: false,
return posts.nodes.map(
({ frontmatter: { slug, lang, title, date, tags }, excerpt }) => {
let path = `/${lang}/blog/${slug}/`

return {
title,
description: excerpt,
date,
author: 'Nikita Kirsanov',
url: `${site.siteMetadata.siteUrl}${path}`,
guid: path,
categories: tags,
}
),
date: node.createdAt,
author: 'Nikita Kirsanov',
url: `${site.siteMetadata.siteUrl}/blog/${node.slug}/`,
guid: `${site.siteMetadata.siteUrl}/blog/${node.slug}/`,
categories: node.tags,
}))
}
)
},
query: `
{
posts: allContentfulBlog(sort: { fields: [createdAt], order: DESC }) {
edges {
node {
posts: allMarkdownRemark(filter: {fileAbsolutePath: {regex: "_content/blog/"}}, sort: {fields: frontmatter___date, order: DESC}) {
nodes {
frontmatter {
slug
lang
title
createdAt
preface {
childContentfulRichText {
html
}
}
date
tags
}
excerpt(pruneLength: 500)
}
}
}
`,
output: '/rss.xml',
output: 'blog/rss.xml',
title: 'Personal blog of software engineer - Nikita Kirsanov',
},
],

0 comments on commit fc4c04a

Please sign in to comment.
You can’t perform that action at this time.