我可以使用Liquid模板在Jekyll中进行适当的平铺分页吗? [英] Can I have a proper nice tiled pagination in Jekyll using Liquid templates?

查看:82
本文介绍了我可以使用Liquid模板在Jekyll中进行适当的平铺分页吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我发现了一个很好的jekyll主题: http://www.jacoporabolini.com/emerald/具有漂亮的分页.不幸的是,只有在页面数量很少的情况下,外观才好.如果是我的博客,则如下所示:

I've found this nice jekyll theme: http://www.jacoporabolini.com/emerald/ with good looking pagination. Unfortunately is only good looking when there is a small number of pages. In case of my blog this looks like this:

毫不奇怪,因为代码看起来像这样:

Not surprisingly because the code looks like this:

{% for page in (1..paginator.total_pages) %}

它应该像这样:

 {% for page in (min(1,paginator.page-3)..max(paginator.page+3,paginator.total_pages)) %} 

问题是,我不认为Liquid中有minmax之类的东西,甚至没有+-之类的算术运算符.我正在搜索文档,却找不到minmax.,我也检查了许多主题,它们提供的只是这种幼稚的分页,根本没有分页和第一种当前的分页.任何提示表示赞赏.

The problem is, I don't think there is something like min and max in Liquid or even arithmetic operators like + or -. I was searching though the documentation and couldn't find min or max. I've also checked many themes and all they offer is this naive pagination, no pagination at all and first|current|next type of pagination. Any hints are appreciated.

推荐答案

我写了一个Liquid {% include %},它可以满足您的需求. Jekyll分页器链接.

I wrote a Liquid {% include %} that does what you are looking for. Jekyll Paginator Links.

我基于您使用的逻辑(最小/最大),但是它也内置了更多的数学功能.它可以使用CSS进行自定义,因此它应该能够执行您描述的操作.希望它能满足您的需求!如果没有,请在GitHub上提交问题.

I based it on the logic you used (min/max), but it has a bit more math built in as well. It's customizable with CSS so it should be able to do what you have described. I hope it does what you need it to! If not, submit an issue on GitHub.

这篇关于我可以使用Liquid模板在Jekyll中进行适当的平铺分页吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆