Skip to content

Commit

Permalink
pagination setup done
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohd Danish Yusuf authored and Mohd Danish Yusuf committed Mar 31, 2019
1 parent bb97d8d commit 04a118d
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 9 deletions.
2 changes: 1 addition & 1 deletion components/AddButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const AddButton = () => (
<div style={{textAlign: 'center'}}>
<div className="right-navbar">
<ul>
<li><a href="https://twitter.com/dailyhacknotes" target="_blank"><PlusSquare color={'#4618B1'} size={18} /> <span>Any Tricks?</span></a></li>
<li><a href="https://github.com/mddanishyusuf/dailyhack/issues" target="_blank"><PlusSquare color={'#4618B1'} size={18} /> <span>Any Tricks?</span></a></li>
</ul>
</div>
<style jsx>
Expand Down
6 changes: 4 additions & 2 deletions components/Header.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import Link from 'next/link'
import { withRouter } from 'next/router'

import AddButton from './AddButton'
import { Twitter, GitHub, Users } from 'react-feather';

Expand All @@ -16,7 +18,7 @@ const Header = (props) => (
</ul>
</div>
</div>
{props.pathname === "/" ?
{props.router.pathname === "/" ?
<div className="landing-heading">
<h2>A community of Makers and Geeks</h2>
<p>It's a place where people share there daily hack they use in their developments. So, Do you have any hack?</p>
Expand Down Expand Up @@ -84,4 +86,4 @@ const Header = (props) => (
</div>
)

export default Header;
export default withRouter(Header);
4 changes: 1 addition & 3 deletions components/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ const Layout = props => (
<title>{props.title}</title>
<link href="https://fonts.googleapis.com/css?family=Questrial|Poppins:500" rel="stylesheet"/>
</Head>
<Header {...props.url}/>
<body>
<Header/>
{props.children}
<style jsx global>
{`
Expand All @@ -26,7 +25,6 @@ const Layout = props => (
}
`}
</style>
</body>
</div>
)

Expand Down
23 changes: 21 additions & 2 deletions components/PaginationBox.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
import Link from 'next/link'

function PaginationBox(props){
const paginationArray = Array.from(Array(props.total_issues).keys())
const activePage = props.active_page
const numberOfPages = Math.ceil(props.total_issues / 5)
const paginationArray = Array.from(Array(numberOfPages).keys())
return(
<div className="pagination">
{activePage}
<ul>
{paginationArray.map(number => {
return(
<li key={number}>{number+1}</li>
<li key={number}>
{number+1 === parseInt(activePage) ? <span>{number+1}</span> : <Link as={`/page/${number+1}`} href={`/page?page_number=${number+1}`}><a>{number+1}</a></Link>}
</li>

)
})}
</ul>
Expand All @@ -21,7 +28,19 @@ function PaginationBox(props){
.pagination ul li {
display: inline-block;
}
.pagination ul li a, .pagination ul li span{
padding: 5px;
border: 1px solid #333;
border-radius: 50% 40% 45% 50% / 40% 50% 55% 40%;
padding: 5px 10px;
margin: 3px;
}
.pagination ul li span{
background-color: #4618B1;
color: #fff;
}
`}
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ app
})

server.get('/page/:page_number', (req, res) => {
const actualPage = '/index'
const actualPage = '/'
const page_number = req.params.page_number
const queryParams = { page_number }
app.render(req, res, actualPage, queryParams)
Expand Down

0 comments on commit 04a118d

Please sign in to comment.