-
Notifications
You must be signed in to change notification settings - Fork 2k
/
post-collapse.swig
41 lines (34 loc) · 1.44 KB
/
post-collapse.swig
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
{% macro render(posts) %}
{%- for post in posts.toArray() %}
{%- set current_year %}
{%- set year = date(post.date, 'YYYY') %}
{%- if year !== current_year %}
{%- set current_year = year %}
<div class="collection-year">
<{%- if theme.seo %}h2{% else %}h1{%- endif %} class="collection-header">{{ current_year }}</{%- if theme.seo %}h2{% else %}h1{%- endif %}>
</div>
{%- endif %}
<article itemscope itemtype="http://schema.org/Article">
<header class="post-header">
<div class="post-meta">
<time itemprop="dateCreated"
datetime="{{ moment(post.date).format() }}"
content="{{ date(post.date, config.date_format) }}">
{{ date(post.date, 'MM-DD') }}
</time>
</div>
<{%- if theme.seo %}h3{% else %}h2{%- endif %} class="post-title">
{%- if post.link %}{# Link posts #}
{%- set postTitleIcon = '<i class="fa fa-external-link"></i>' %}
{%- set postText = post.title or post.link %}
{{ next_url(post.link, postText + postTitleIcon, {class: 'post-title-link post-title-link-external', itemprop: 'url'}) }}
{% else %}
<a class="post-title-link" href="{{ url_for(post.path) }}" itemprop="url">
<span itemprop="name">{{ post.title or __('post.untitled') }}</span>
</a>
{%- endif %}
</{%- if theme.seo %}h3{% else %}h2{%- endif %}>
</header>
</article>
{%- endfor %}
{% endmacro %}