Вопрос к тем кто дружит с liquid

M
На сайте с 19.08.2015
Offline
34
1241

Здравствуйте, надеюсь найдутся те кто понимает нормально liquid

Делаю сайт на Jelyll, там используется liquid + yaml

А вопрос по пагинации.

Есть стандартный цикл который реально работает:

{% for post in paginator.posts %}

<a href="{{ post.url }}">{{ post.title }}</a>
{{ post.date }}
{{ post.content }}
{% endfor %}

Но проблема в том, что он тянет вообще все записи со всех категорий... А мне надо указать конкурентную категорию... Нормальной информации не нашел, вот несколько вроде как нормальных сайтов с инструкциями, но и там ничего вразумительного по этому поводу не нашел...

https://help.shopify.com/themes/liquid/objects/paginate#paginate-current_page

https://shopify.github.io/liquid/

Я только изучаю этот язык, на изучение подробное уйдет время, а решить пробл, надо быстро...

Помогите пожалуйста.

S1
На сайте с 15.09.2016
Offline
9
#1

{% for post in paginator.posts %}

{% if post.category == 'category_name' %}
<a href="{{ post.url }}">{{ post.title }}</a>
{{ post.date }}
{{ post.content }}
{% endif %}
{% endfor %}
SEO анализ сайта (https://seo11.ru/)
M
На сайте с 19.08.2015
Offline
34
#2
seo11:
{% for post in paginator.posts %}

{% if post.category == 'category_name' %}
<a href="{{ post.url }}">{{ post.title }}</a>
{{ post.date }}
{{ post.content }}
{% endif %}
{% endfor %}

Здравствуйте, решение отличное, только вот не работает((

Вот как делаю:

{% for post in paginator.posts %}

{% if post.category == 'category_publication' %}
<a href="{{ post.url }}">{{ post.title }}</a>
{% endif %}
{% endfor %}

<!-- Pagination links -->
<div class="pagination">
{% if paginator.previous_page %}
<a href="{{ paginator.previous_page_path }}" class="previous">Previous</a>
{% else %}
<span class="previous">Previous</span>
{% endif %}
<span class="page_number ">Page: {{ paginator.page }} of {{ paginator.total_pages }}</span>
{% if paginator.next_page %}
<a href="{{ paginator.next_page_path }}" class="next">Next</a>
{% else %}
<span class="next ">Next</span>
{% endif %}
</div>

Инструкция по пагинации для jekyll вот:

https://jekyllrb.com/docs/pagination/

То там как говорил нет решения...

Может ещё есть идеи какие?

S1
На сайте с 15.09.2016
Offline
9
#3
Mazletop:
решение отличное, только вот не работает((

На чистом liquid сработало бы. А тут какие-то ограничения самого jekyll. Вот что они пишут в документации:

Pagination does not support tags or categories

It does not currently allow paging over groups of posts linked by a common tag or category. It cannot include any collection of documents because it is restricted to posts.

M
На сайте с 19.08.2015
Offline
34
#4
seo11:
На чистом liquid сработало бы. А тут какие-то ограничения самого jekyll. Вот что они пишут в документации:
Pagination does not support tags or categories
It does not currently allow paging over groups of posts linked by a common tag or category. It cannot include any collection of documents because it is restricted to posts.

Спасибо друг за помощь.

--

Ты не работал с Jekyll? Есть опыт работы с этим генератором?

Авторизуйтесь или зарегистрируйтесь, чтобы оставить комментарий