about summary refs log tree commit diff
path: root/templates/macros/posts.html
blob: 506adff23f7b69736cb1f5d07dc3996d8416fd57 (plain)
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
59
60
61
{% macro display(pages) %}
  <div class="article-list">
    <!-- If you are using pagination, section.pages will be empty. You need to use the paginator object -->
    {% for page in pages %}
      <article>
        <header lang="{{ page.lang }}">
          <time datetime="{{ page.date }}">{{ page.date }}</time>
          <h3>{{ posts::link(page=page) }}</h3>
          <p class="post-meta">{{ posts::taxonomies(taxonomies=page.taxonomies) }}</p>
        </header>
      </article>
    {% endfor %}
</div>
{% endmacro display %}

{% macro link(page) %}
  <a href="{{ page.permalink | safe }}">{{ page.title }}</a>
{% endmacro link %}

{% macro meta(page) %}
  {% if page.date %}
    Published on {{ page.date }}
  {% endif %}
  {% if page.updated %}
    | Edited on {{ page.updated }}
  {% endif %}
  {% if page.taxonomies %}
    :: {{ posts::taxonomies(taxonomies=page.taxonomies) }}
  {% endif %}
{% endmacro meta %}

{% macro taxonomies(taxonomies) %}
  {% if taxonomies.categories %}
    {{ posts::categories(categories=taxonomies.categories) }}
  {% endif %}
  {% if taxonomies.tags %}
    {{ posts::tags(tags=taxonomies.tags) }}
  {% endif %}
{% endmacro taxonomies %}

{% macro categories(categories) %}
  [
  {% for category in categories %}
    {% if loop.last %}
      <a href="{{ get_taxonomy_url(kind="categories", name=category) }}">{{ category }}</a>
    {% else %}
      <a href="{{ get_taxonomy_url(kind="categories", name=category) }}">{{ category }}</a>,
    {% endif %}
  {% endfor %}
  ]
{% endmacro categories %}

{% macro tags(tags) %}
  {% for tag in tags %}
    {% if loop.last %}
      #<a href="{{ get_taxonomy_url(kind="tags", name=tag) }}">{{ tag }}</a>
    {% else %}
      #<a href="{{ get_taxonomy_url(kind="tags", name=tag) }}">{{ tag }}</a>,
    {% endif %}
  {% endfor %}
{% endmacro tags %}