Can I have a proper nice tiled pagination in Jekyll using Liquid templates?

喜夏-厌秋 提交于 2020-01-11 09:35:29

问题


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) %}

And it should like more like this:

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

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.


回答1:


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

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.



来源:https://stackoverflow.com/questions/30125878/can-i-have-a-proper-nice-tiled-pagination-in-jekyll-using-liquid-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!