2016-03-11 23:28:19 +01:00
|
|
|
import React from 'react'
|
|
|
|
import { Link } from 'react-router'
|
|
|
|
import { prune, include as includes } from 'underscore.string'
|
|
|
|
import find from 'lodash/find'
|
|
|
|
|
|
|
|
import './style.sss'
|
|
|
|
|
|
|
|
class ReadNext extends React.Component {
|
2016-03-21 18:03:01 +01:00
|
|
|
render() {
|
|
|
|
const {pages, post} = this.props
|
|
|
|
const {readNext} = post
|
2016-03-11 23:28:19 +01:00
|
|
|
|
2016-03-21 18:03:01 +01:00
|
|
|
let nextPost
|
|
|
|
if (readNext) {
|
|
|
|
nextPost = find(pages, (page) => includes(page.path, readNext)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (!nextPost) {
|
|
|
|
return React.createElement('noscript', null)
|
|
|
|
} else {
|
|
|
|
nextPost = find(pages, (page) => includes(page.path, readNext.slice(1, -1))
|
|
|
|
)
|
|
|
|
const description = nextPost.data.description
|
2016-03-11 23:28:19 +01:00
|
|
|
|
2016-03-21 18:03:01 +01:00
|
|
|
return (
|
|
|
|
<div>
|
|
|
|
<h6 style={ { fontSize: '16px', margin: '20px 0 0'} }>READ THIS NEXT:</h6>
|
|
|
|
<h3 style={ { margin: '5px 0 0'} }><Link to={ nextPost.path } query={ { readNext: true} } > { nextPost.data.title } </Link></h3>
|
|
|
|
<p className='description'>
|
|
|
|
{ description }
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
2016-03-11 23:28:19 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReadNext.propTypes = {
|
2016-03-21 18:03:01 +01:00
|
|
|
post: React.PropTypes.object.isRequired,
|
|
|
|
pages: React.PropTypes.array,
|
2016-03-11 23:28:19 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
export default ReadNext
|