From 4d97a16d53d70d34d931943026c85039f083dc56 Mon Sep 17 00:00:00 2001 From: StevenJoeZhang <1119186082@qq.com> Date: Mon, 5 Aug 2019 18:38:31 +0800 Subject: [PATCH] Update --- layout/_macro/post-collapse.swig | 16 +++++++++++++++- layout/archive.swig | 18 +----------------- layout/category.swig | 18 +----------------- layout/tag.swig | 18 +----------------- 4 files changed, 18 insertions(+), 52 deletions(-) diff --git a/layout/_macro/post-collapse.swig b/layout/_macro/post-collapse.swig index a3eb3b5c97..7fca6ff606 100644 --- a/layout/_macro/post-collapse.swig +++ b/layout/_macro/post-collapse.swig @@ -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 %} +
+ <{%- if theme.seo %}h2{% else %}h1{%- endif %} class="archive-year" id="archive-year-{{ year }}">{{ year }} +
+ {%- endif %} + {# endshow #}
@@ -30,4 +43,5 @@
+{%- endfor %} {% endmacro %} diff --git a/layout/archive.swig b/layout/archive.swig index 24b2936832..2a93250390 100644 --- a/layout/archive.swig +++ b/layout/archive.swig @@ -31,23 +31,7 @@ {%- 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 %} -
- <{%- if theme.seo %}h2{% else %}h1{%- endif %} class="archive-year" id="archive-year-{{ year }}">{{ year }} -
- {%- endif %} - {# endshow #} - - {{ post_template.render(post) }} - - {%- endfor %} + {{ post_template.render(page.posts) }} diff --git a/layout/category.swig b/layout/category.swig index a35120380b..1e4b0c32b1 100644 --- a/layout/category.swig +++ b/layout/category.swig @@ -19,23 +19,7 @@ - {%- for post in page.posts %} - - {# Show year #} - {%- set year %} - {%- set post.year = date(post.date, 'YYYY') %} - - {%- if post.year !== year %} - {%- set year = post.year %} -
- <{%- if theme.seo %}h2{% else %}h1{%- endif %} class="archive-year" id="archive-year-{{ year }}">{{ year }} -
- {%- endif %} - {# endshow #} - - {{ post_template.render(post) }} - - {%- endfor %} + {{ post_template.render(page.posts) }} diff --git a/layout/tag.swig b/layout/tag.swig index 35cd7b6ed1..8af5dc8c2c 100644 --- a/layout/tag.swig +++ b/layout/tag.swig @@ -19,23 +19,7 @@ - {%- for post in page.posts %} - - {# Show year #} - {%- set year %} - {%- set post.year = date(post.date, 'YYYY') %} - - {%- if post.year !== year %} - {%- set year = post.year %} -
- <{%- if theme.seo %}h2{% else %}h1{%- endif %} class="archive-year" id="archive-year-{{ year }}">{{ year }} -
- {%- endif %} - {# endshow #} - - {{ post_template.render(post) }} - - {%- endfor %} + {{ post_template.render(page.posts) }}