Proper HistoryNav

Detects whether there's a previous page or next page, the old HistoryNav
was made to be dumber and most of the logic now lives in Posts (which is
the only thing that uses HistoryNav anyway)

The side-effect is that the nav is now within the content column, which
is okay since it's symmetric now.
This commit is contained in:
Nick Pegg 2017-10-07 17:31:33 -07:00
parent 04a4e8a93f
commit 9fad879181
3 changed files with 80 additions and 42 deletions

View file

@ -71,39 +71,34 @@ 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);
}
const HistoryNav = (props) => {
let left = "";
let right = "";
let left = "";
if (page !== 0) {
let last_href = "/page/" + (page - 1);
if (page === 1) {
last_href = "/";
}
left = (
<Link to={last_href}>
<Icon name="arrow-left" />
<span> newer posts</span>
</Link>
)
}
let next_href = "/page/" + (page + 1);
return (
<Row>
{ left }
<Link className="u-pull-right" to={next_href}>
<span>older posts </span>
<Icon name="arrow-right" />
</Link>
</Row>
if (props.prev) {
left = (
<Link to={props.prev}>
<Icon name="arrow-left" />
<span> newer posts</span>
</Link>
);
}
if (props.next) {
right = (
<Link className="u-pull-right" to={props.next}>
<span>older posts </span>
<Icon name="arrow-right" />
</Link>
);
}
return (
<Row>
{ left }
{ right }
</Row>
)
}
export { ListLink, NavList, TagNav, HistoryNav };