Skip to content

Commit a30b2b6

Browse files
committed
修复集合文章上一页/下一页可能错误跳转至其它语言的问题
1 parent 5fb2422 commit a30b2b6

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

_includes/post_pagination.html

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,22 @@
11
{% assign locale = include.locale | default: page.locale | default: layout.locale | default: site.locale %}
2-
{% if page.previous or page.next %}
2+
{%- assign next = page.next -%}
3+
{%- assign previous = page.previous -%}
4+
{%- assign collection = site.collections | where: "label", page.collection | first -%}
5+
{%- for document in collection.docs -%}
6+
{%- if page.locale == next.locale and page.locale == previous.locale %}{% break %}{% endif -%}
7+
{%- if page.locale != next.locale %}{% assign next = next.next %}{% endif -%}
8+
{%- if page.locale != previous.locale %}{% assign previous = previous.previous %}{% endif -%}
9+
{%- endfor -%}
10+
11+
{% if previous or next %}
312
<nav class="pagination">
4-
{% if page.previous %}
5-
<a href="{{ page.previous.url | relative_url }}" class="pagination--pager" title="{{ page.previous.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[locale].pagination_previous | default: "Previous" }}</a>
13+
{% if previous %}
14+
<a href="{{ previous.url | relative_url }}" class="pagination--pager" title="{{ previous.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[locale].pagination_previous | default: "Previous" }}</a>
615
{% else %}
716
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[locale].pagination_previous | default: "Previous" }}</a>
817
{% endif %}
9-
{% if page.next %}
10-
<a href="{{ page.next.url | relative_url }}" class="pagination--pager" title="{{ page.next.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[locale].pagination_next | default: "Next" }}</a>
18+
{% if next %}
19+
<a href="{{ next.url | relative_url }}" class="pagination--pager" title="{{ next.title | markdownify | strip_html | strip}}">{{ site.data.ui-text[locale].pagination_next | default: "Next" }}</a>
1120
{% else %}
1221
<a href="#" class="pagination--pager disabled">{{ site.data.ui-text[locale].pagination_next | default: "Next" }}</a>
1322
{% endif %}

0 commit comments

Comments
 (0)