web/_layouts/home.html

123 lines
3.8 KiB
HTML
Raw Normal View History

2019-09-30 15:38:41 +03:00
---
layout: default
2023-09-29 23:46:40 +03:00
refactor: true
2019-09-30 15:38:41 +03:00
---
{% include lang.html %}
{% assign all_pinned = site.posts | where: 'pin', 'true' %}
{% assign all_normal = 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 on current page -->
2020-06-06 07:45:33 +03:00
{% assign visible_start = paginator.page | minus: 1 | times: paginator.per_page %}
{% assign visible_end = visible_start | plus: paginator.per_page %}
2020-06-06 07:45:33 +03:00
{% if all_pinned.size > visible_start %}
{% if all_pinned.size > visible_end %}
{% assign pinned_size = paginator.per_page %}
{% else %}
{% assign pinned_size = all_pinned.size | minus: visible_start %}
{% endif %}
{% for i in (visible_start..all_pinned.size) limit: pinned_size %}
{% assign posts = posts | push: all_pinned[i] %}
2020-06-06 07:45:33 +03:00
{% endfor %}
{% else %}
{% assign pinned_size = 0 %}
2020-06-06 07:45:33 +03:00
{% endif %}
<!-- Get normal posts on current page -->
2020-06-06 07:45:33 +03:00
{% assign normal_size = paginator.posts | size | minus: pinned_size %}
2020-06-06 07:45:33 +03:00
{% if normal_size > 0 %}
{% if pinned_size > 0 %}
{% assign normal_start = 0 %}
{% else %}
{% assign normal_start = visible_start | minus: all_pinned.size %}
{% endif %}
2020-06-06 07:45:33 +03:00
{% assign normal_end = normal_start | plus: normal_size | minus: 1 %}
2020-06-06 07:45:33 +03:00
{% for i in (normal_start..normal_end) %}
{% assign posts = posts | push: all_normal[i] %}
2020-06-06 07:45:33 +03:00
{% endfor %}
{% endif %}
2023-09-29 23:46:40 +03:00
<div id="post-list" class="flex-grow-1 px-xl-1">
{% for post in posts %}
<article class="card-wrapper card">
<a href="{{ post.url | relative_url }}" class="post-preview row g-0 flex-md-row-reverse">
{% assign card_body_col = '12' %}
{% if post.image %}
{% assign src = post.image.path | default: post.image %}
{% unless src contains '//' %}
{% assign src = post.media_subpath | append: '/' | append: src | replace: '//', '/' %}
{% endunless %}
{% assign alt = post.image.alt | xml_escape | default: 'Preview Image' %}
2023-09-29 23:46:40 +03:00
{% assign lqip = null %}
{% if post.image.lqip %}
{% capture lqip %}lqip="{{ post.image.lqip }}"{% endcapture %}
{% endif %}
<div class="col-md-5">
2023-09-29 23:46:40 +03:00
<img src="{{ src }}" alt="{{ alt }}" {{ lqip }}>
</div>
{% assign card_body_col = '7' %}
{% endif %}
<div class="col-md-{{ card_body_col }}">
<div class="card-body d-flex flex-column">
<h1 class="card-title my-2 mt-md-0">{{ post.title }}</h1>
<div class="card-text content mt-0 mb-3">
<p>{% include post-description.html %}</p>
</div>
<div class="post-meta flex-grow-1 d-flex align-items-end">
<div class="me-auto">
<!-- posted date -->
<i class="far fa-calendar fa-fw me-1"></i>
{% include datetime.html date=post.date lang=lang %}
<!-- categories -->
{% if post.categories.size > 0 %}
<i class="far fa-folder-open fa-fw me-1"></i>
<span class="categories">
{% for category in post.categories %}
{{ category }}
{%- unless forloop.last -%},{%- endunless -%}
{% endfor %}
</span>
{% endif %}
</div>
{% if post.pin %}
<div class="pin ms-1">
<i class="fas fa-thumbtack fa-fw"></i>
<span>{{ site.data.locales[lang].post.pin_prompt }}</span>
</div>
{% endif %}
</div>
<!-- .post-meta -->
</div>
<!-- .card-body -->
</div>
</a>
</article>
{% endfor %}
</div>
<!-- #post-list -->
2019-09-30 15:38:41 +03:00
{% if paginator.total_pages > 1 %}
2020-02-22 02:09:09 +03:00
{% include post-paginator.html %}
2019-09-30 15:38:41 +03:00
{% endif %}