Can I have a proper nice tiled pagination in Jekyl

2019-02-25 13:27发布

问题:

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.