github - Jekyll 为类别帖子分页

标签 github pagination jekyll liquid

我已经实现了this example-site ,这不是一个真正的网站,只是一个例子,我在网站的右侧列出了类别,它们实际上是页面,每个页面都是一个类别(没有为此使用的插件)。

他们不会使用标准方法查询帖子,如下所示

{% for post in site.categories %}
   {{the post}}
{ endfor }

但是在每个页面(类别)中都是这样,我循环如此

{% for post in site.posts %}


{% assign cat = page.title %}

{% assign post_cat = post.categories | join: '-' %}

{% if post_cat contains cat %}
    here goes the posts...
{% endif %}


{% endfor %}

我这样做是因为正如 jekyll 文档中所写,分页无法通过标签或类别查询帖子

  • Pagination does not support tags or categories Pagination pages through every post in the posts variable regardless of variables defined in the YAML Front Matter of each. It does not currently allow paging over groups of posts linked by a common tag or category. *

source

我想如果每个类别(在这种情况下每个页面 - index.html)都有自己的index.html,我可以对类别进行分页,但不幸的是我不能。

主页分页如您所见

here is the site

here is the site's source

我不想为此使用插件,因为所有诸如“通过标签相关帖子”,“每个帖子类别链接到其类别页面”,以及我在没有插件的情况下所做的其他事情,因此可以直接编写帖子来自 github。

如何对类别的帖子进行分页?

在源代码中,有文件夹类别,这里 - 其文件夹中的每个类别

最佳答案

目前还不能。

如果你想让它工作,你需要为此创建一个插件。我使用纯 jekyll(无插件)构建了相当多的模板,这是您无法绕过的限制之一。

关于github - Jekyll 为类别帖子分页,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20600248/

相关文章:

github repo 按语言(和历史数据)计算?

git - 防止 Git 远程分支被删除

git - 开源项目时处理以前的提交

ruby-on-rails - 对大量记录进行分页

ruby - Jekyll - 如何在父文件夹中使用 Markdown 文件

github - BitBucket/GitLab 是否有贡献或事件图表,就像 GitHub 一样?

php - 在搜索数据库中插入分页。 PHP MySQL

php - 结果分页(mysql+php)取决于下拉菜单过滤器

github - 生成带有导航元素的 github 页面

yaml - 努力在 Jekyll 配置文件中找到数组(站点导航)