web/_layouts/home.html

96 lines
2.6 KiB
HTML
Raw Normal View History

2019-09-30 15:38:41 +03:00
---
layout: page
# The Home page layout
---
{% include lang.html %}
{% assign pinned = site.posts | where: 'pin', 'true' %}
{% assign default = site.posts | where_exp: 'item', 'item.pin != true and item.hidden != true' %}
2020-06-06 07:45:33 +03:00
{% assign posts = '' | split: '' %}
2020-06-06 07:45:33 +03:00
<!-- Get pinned posts -->
{% assign offset = paginator.page | minus: 1 | times: paginator.per_page %}
{% assign pinned_num = pinned.size | minus: offset %}
{% if pinned_num > 0 %}
{% for i in (offset..pinned.size) limit: pinned_num %}
{% assign posts = posts | push: pinned[i] %}
{% endfor %}
{% else %}
{% assign pinned_num = 0 %}
{% endif %}
2020-06-08 16:44:59 +03:00
<!-- Get default posts -->
2020-06-06 07:45:33 +03:00
{% assign default_beg = offset | minus: pinned.size %}
{% if default_beg < 0 %}
{% assign default_beg = 0 %}
{% endif %}
{% assign default_num = paginator.posts | size | minus: pinned_num %}
2020-06-06 07:45:33 +03:00
{% assign default_end = default_beg | plus: default_num | minus: 1 %}
{% if default_num > 0 %}
{% for i in (default_beg..default_end) %}
{% assign posts = posts | push: default[i] %}
{% endfor %}
{% endif %}
2019-09-30 15:38:41 +03:00
<div id="post-list">
{% for post in posts %}
<div class="card post-preview">
<a href="{{ post.url | relative_url }}">
<div class="card-body">
<h1 class="card-title">
{{ post.title }}
</h1>
<div class="card-text post-content">
<p>
{% include no-linenos.html content=post.content %}
{{ content | markdownify | strip_html | truncate: 200 | escape }}
</p>
</div>
<div class="post-meta text-muted d-flex">
<div class="mr-auto">
<!-- posted date -->
<i class="far fa-calendar fa-fw"></i>
{% include datetime.html date=post.date lang=lang %}
<!-- categories -->
{% if post.categories.size > 0 %}
<i class="far fa-folder-open fa-fw"></i>
<span>
{% for category in post.categories %}
{{ category }}
{%- unless forloop.last -%},{%- endunless -%}
{% endfor %}
</span>
{% endif %}
</div>
{% if post.pin %}
<div class="pin">
<i class="fas fa-thumbtack fa-fw"></i>
<span>{{ site.data.locales[lang].post.pin_prompt }}</span>
</div>
{% endif %}
</div>
<!-- .post-meta -->
</div>
</a>
2019-09-30 15:38:41 +03:00
</div>
<!-- .post-review -->
{% endfor %}
</div>
<!-- #post-list -->
2019-09-30 15:38:41 +03:00
{% if paginator.total_pages > 0 %}
2020-02-22 02:09:09 +03:00
{% include post-paginator.html %}
2019-09-30 15:38:41 +03:00
{% endif %}