File tree Expand file tree Collapse file tree 1 file changed +26
-2
lines changed
Expand file tree Collapse file tree 1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -9,8 +9,14 @@ import MetaInfo from '../components/meta-info';
99import Page from '../components/page' ;
1010import Lead from '../components/lead' ;
1111import theme from '../theme' ;
12+ import Button from '../components/button' ;
1213
13- function Blog ( { data } ) {
14+ function Blog ( { data, pageContext } ) {
15+ const { currentPage, limit, numPages, skip } = pageContext
16+ const isFirst = currentPage === 1
17+ const isLast = currentPage === numPages
18+ const prevPage = currentPage - 1 === 1 ? "" : ( currentPage - 1 ) . toString ( )
19+ const nextPage = ( currentPage + 1 ) . toString ( )
1420 return (
1521 < Layout >
1622 < Helmet >
@@ -36,7 +42,25 @@ function Blog({ data }) {
3642 < Lead > { node . frontmatter . description } </ Lead >
3743 </ article >
3844 ) ) }
39- { /* TODO: pagination */ }
45+ < div css = { css `
46+ display: flex;
47+ justify-content: space-between;
48+ ` } >
49+ { ! isFirst && (
50+ < Button href = { `/blog/${ prevPage } ` } rel = "prev" className = 'primary' css = { css `
51+ margin: ${ theme . space [ 4 ] } 0;
52+ ` } >
53+ ← Previous Page
54+ </ Button >
55+ ) }
56+ { ! isLast && (
57+ < Button href = { `/blog/${ nextPage } ` } rel = "next" className = 'primary' css = { css `
58+ margin: ${ theme . space [ 4 ] } 0;
59+ ` } >
60+ Next Page →
61+ </ Button >
62+ ) }
63+ </ div >
4064 </ Container >
4165 </ Page >
4266 </ Layout >
You can’t perform that action at this time.
0 commit comments