Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Show year devision in category or tag page #1061

Merged
merged 2 commits into from
Aug 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion layout/_macro/post-collapse.swig
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
{% macro render(post) %}
{% macro render(posts) %}
{%- for post in posts %}

{# Show year #}
{%- set year %}
{%- set post.year = date(post.date, 'YYYY') %}

{%- if post.year !== year %}
{%- set year = post.year %}
<div class="collection-title">
<{%- if theme.seo %}h2{% else %}h1{%- endif %} class="archive-year" id="archive-year-{{ year }}">{{ year }}</{%- if theme.seo %}h2{% else %}h1{%- endif %}>
</div>
{%- endif %}
{# endshow #}

<article class="post post-type-{{ post.type | default('normal') }}" itemscope itemtype="http://schema.org/Article">
<header class="post-header">
Expand Down Expand Up @@ -30,4 +43,5 @@
</header>
</article>

{%- endfor %}
{% endmacro %}
18 changes: 1 addition & 17 deletions layout/archive.swig
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,7 @@
</span>
{%- endif %}

{%- for post in page.posts %}

{# Show year #}
{%- set year %}
{%- set post.year = date(post.date, 'YYYY') %}

{%- if post.year !== year %}
{%- set year = post.year %}
<div class="collection-title">
<{%- if theme.seo %}h2{% else %}h1{%- endif %} class="archive-year" id="archive-year-{{ year }}">{{ year }}</{%- if theme.seo %}h2{% else %}h1{%- endif %}>
</div>
{%- endif %}
{# endshow #}

{{ post_template.render(post) }}

{%- endfor %}
{{ post_template.render(page.posts) }}

</div>
</div>
Expand Down
4 changes: 1 addition & 3 deletions layout/category.swig
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
</{%- if theme.seo %}h2{% else %}h1{%- endif %}>
</div>

{%- for post in page.posts %}
{{ post_template.render(post) }}
{%- endfor %}
{{ post_template.render(page.posts) }}
</div>

</div>
Expand Down
4 changes: 1 addition & 3 deletions layout/tag.swig
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,7 @@
</{%- if theme.seo %}h2{% else %}h1{%- endif %}>
</div>

{%- for post in page.posts %}
{{ post_template.render(post) }}
{%- endfor %}
{{ post_template.render(page.posts) }}
</div>

</div>
Expand Down