summaryrefslogtreecommitdiffstats
path: root/src/themes/serene/templates/posts.html
blob: 9b3dec1d70e9a37b99565ee9362243ccda5e81d7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
{% extends "_base.html" %}

{% block page %}blog{% endblock page%}
{% block lang %}{% if section.extra.lang %}{{ section.extra.lang }}{% else %}{{ section.lang }}{% endif %}{% endblock lang %}
{% block title %}{{ section.title }}{% endblock title %}
{% block desc %}
  {% if section.description %}
    {% set desc = section.description %}
  {% else %}
    {% set desc = config.description %}
  {% endif %}
  {%- if section.extra.lang %}{% set og_lang = section.extra.lang %}{% else %}{% set og_lang = section.lang %}{% endif -%}
  {{ <seo config
      title={section.title}
      desc={desc}
      url={section.permalink}
      lang={og_lang} /> }}
{% endblock desc %}

{% block content %}
<div id="wrapper">
  {{ <back_link path={get_url(path="/")} config /> }}
  {% include "_section_title.html" %}
  <main class="layout-list">
    {% set date_format = section.extra.date_format if section.extra.date_format is defined else (config.extra.date_format if config.extra.date_format is defined else "%b %-d, %Y") %}
    {% if section.extra.categorized %}
    {% set categorized_posts = [post for post in section.pages if post.taxonomies?.categories] %}
    {% set categories = [post.taxonomies.categories[0] for post in categorized_posts] | unique | sort %}
    {% for category in categories %}
    {% set posts = [post for post in categorized_posts if post.taxonomies.categories[0] == category] %}
    {% set category_name = category %}
    {% if category is matching(pat="^__[0-9]{2}__") %}
      {% set category_name = category[6:] %}
    {% endif %}
    <h2 class="category">{{ category_name }}</h2>
    <div class="post-list categorized">
      {% for post in posts %}
      <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink }}">
        <span>{{ post.title }}</span>
        <span class="date">{{ post.date | date(format=date_format) }}</span>
      </a>
      {% endfor %}
    </div>
    {% endfor %}
    {% else %}
    <div class="post-list">
      {% for post in section.pages %}
      <a class="post instant {% if post.extra.featured %}featured{% endif %}" href="{{ post.permalink }}">
        <span>{{ post.title }}</span>
        <span class="date">{{ post.date | date(format=date_format) }}</span>
      </a>
      {% endfor %}
    </div>
    {% endif %}
  </main>
  {% include "_footer.html" %}
</div>
{% endblock content %}