I am trying to create pagination for my blog in Gatsby. I have managed to get the pagination to kinda work.
When I go to localhost:8000/posts
I get the whole list of my blog posts.
When I go to localhost:8000/posts/2
I get the list of paginated posts, only showing 3 posts.
When I try to access the post say http://localhost:8000/posts/loading-css-via-prefers-color-scheme/
I get a TypeError: Cannot read property 'page' of undefined
which is throwing me off as this is my dir:
│ ├── posts
│ │ ├── breaking-jekyll-posts-into-years.md
│ │ ├── cleaning-up-git.md
│ │ ├── converting-dates-from-api-repsonses-in-django.md
│ │ ├── css-dark-mode.md
│ │ ├── generating-ssh-keys.md
│ │ ├── getting-api-data-into-your-templates-with-django.md
│ │ ├── imgs
│ │ ├── loading-css-via-prefers-color-scheme.md
│ │ ├── sticky-footer-with-flexbox.md
│ │ └── writing-a-changelog.md
│ └── templates
│ ├── post-list.js
│ └── post.js
This is my template for the paginated posts
And this is my gatsby node file
I have two questions following on from the above.
- Where am i going wrong, in relation to being able to click through to the actual post.
- How can i display the paginated posts on the url
localhost:8000/posts
instead of the whole lot...is this just a templating issue I am not seeing? Can i use a template within a page? Or can i use a template as an page?