add linking to previous and next post
This commit is contained in:
parent
a8a8f64575
commit
1a862b7fab
2 changed files with 40 additions and 4 deletions
|
|
@ -1,5 +1,6 @@
|
|||
import React from 'react'
|
||||
import Helmet from 'react-helmet'
|
||||
import Link from 'gatsby-link'
|
||||
import get from 'lodash/get'
|
||||
|
||||
import Bio from '../components/Bio'
|
||||
|
|
@ -9,6 +10,7 @@ class BlogPostTemplate extends React.Component {
|
|||
render() {
|
||||
const post = this.props.data.markdownRemark
|
||||
const siteTitle = get(this.props, 'data.site.siteMetadata.title')
|
||||
const { previous, next } = this.props.pathContext;
|
||||
|
||||
return (
|
||||
<div>
|
||||
|
|
@ -31,6 +33,30 @@ class BlogPostTemplate extends React.Component {
|
|||
}}
|
||||
/>
|
||||
<Bio />
|
||||
|
||||
<ul style={{
|
||||
display: 'flex',
|
||||
flexWrap: 'wrap',
|
||||
justifyContent: 'space-between',
|
||||
listStyle: 'none',
|
||||
padding: 0,
|
||||
}}>
|
||||
{ previous && (
|
||||
<li>
|
||||
<Link to={previous.fields.slug} rel="prev">
|
||||
← {previous.frontmatter.title}
|
||||
</Link>
|
||||
</li>
|
||||
) }
|
||||
|
||||
{ next && (
|
||||
<li>
|
||||
<Link to={next.fields.slug} rel="next">
|
||||
{next.frontmatter.title} →
|
||||
</Link>
|
||||
</li>
|
||||
) }
|
||||
</ul>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue