我正在尝试在 Gatsby 中为我的博客创建分页。我已经设法让分页有点工作。
当我去时,localhost:8000/posts我会得到我的博客文章的完整列表。当我去时,localhost:8000/posts/2我得到了分页帖子的列表,只显示了 3 个帖子。
当我尝试访问该帖子时,说http://localhost:8000/posts/loading-css-via-prefers-color-scheme/我得到了一个TypeError: Cannot read property 'page' of undefined让我失望的消息,因为这是我的目录:
│ ├── 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
这是我的分页帖子模板
这是我的gatsby 节点文件
根据以上内容,我有两个问题。
关于能够点击到实际帖子,我哪里出错了。
我怎样才能在 url 上显示分页的帖子localhost:8000/posts而不是全部......这只是我没有看到的模板问题吗?我可以在页面中使用模板吗?或者我可以使用模板作为页面吗?
繁花如伊
catspeake
随时随地看视频慕课网APP
相关分类