Compare commits
2 Commits
5a956cb708
...
0c9279805e
Author | SHA1 | Date | |
---|---|---|---|
0c9279805e | |||
9caedb3f87 |
5
app.js
5
app.js
@ -103,6 +103,11 @@ function getAllBlogPosts(page = 1, postsPerPage = 5) {
|
|||||||
// Home Route (Blog Home with Pagination)
|
// Home Route (Blog Home with Pagination)
|
||||||
app.get('/', (req, res) => {
|
app.get('/', (req, res) => {
|
||||||
const page = parseInt(req.query.page) || 1;
|
const page = parseInt(req.query.page) || 1;
|
||||||
|
|
||||||
|
if (page < 1) {
|
||||||
|
return res.redirect(req.hostname);
|
||||||
|
}
|
||||||
|
|
||||||
const postsPerPage = 5; // Set how many posts to display per page
|
const postsPerPage = 5; // Set how many posts to display per page
|
||||||
|
|
||||||
const { blogPosts, totalPages } = getAllBlogPosts(page, postsPerPage);
|
const { blogPosts, totalPages } = getAllBlogPosts(page, postsPerPage);
|
||||||
|
Loading…
Reference in New Issue
Block a user