HistoryNav working with routing

This commit is contained in:
Nick Pegg 2017-10-07 12:27:33 -07:00
parent 0968c22cf6
commit 5d799021f0
2 changed files with 23 additions and 14 deletions

View file

@ -73,29 +73,38 @@ class TagNav extends Component {
class HistoryNav extends Component {
render() {
let page = 0;
if (this.props.match.params.page) {
page = parseInt(this.props.match.params.page, 10);
}
console.log('nav page', page);
let left = "";
if (!this.props.newest) {
if (page !== 0) {
let last_href = "/page/" + (page - 1);
if (page === 1) {
last_href = "/";
}
left = (
<a href="">
<Icon name="arrow-left" />
<span> newer posts</span>
</a>
<Link to={last_href}>
<Icon name="arrow-left" />
<span> newer posts</span>
</Link>
)
}
let next_href = "/page/" + (page + 1);
return (
<Row>
{ left }
<a className="u-pull-right" href="">
<Link className="u-pull-right" to={next_href}>
<span>older posts </span>
<Icon name="arrow-right" />
</a>
</Link>
</Row>
);
}
}
const HistoryNavStart = ({match}) => (
<HistoryNav newest />
)
export { ListLink, NavList, TagNav, HistoryNav, HistoryNavStart };
export { ListLink, NavList, TagNav, HistoryNav };