diff options
Diffstat (limited to 'templates/posts.html')
| -rw-r--r-- | templates/posts.html | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/templates/posts.html b/templates/posts.html index 92c07dc..13dc274 100644 --- a/templates/posts.html +++ b/templates/posts.html @@ -1,4 +1,7 @@ -{# This Page Shows the Posts Grouped by Year: example.com/posts/ #} +{# +This Page Shows the Posts Grouped by Year: example.com/posts/ +This Template can also be used as the rendering template for Sections, eg: example.com/blog/ example.com/software/ +#} {% extends "base.html" %} @@ -18,14 +21,30 @@ {%- endblock seo %} {%- block content %} + {#- The following line is checking if the template is being used for the posts page or a section #} + {%- if current_path is matching("^(/[[:alpha:]][[:alpha:]])?/posts/$") %} + {%- set sec = "" %} + {%- else %} + {%- set langpath = "/" %} + {%- if lang != config.default_language %} + {%- set langpath = "/" ~ lang ~ "/" %} + {%- endif %} + + {%- set sec = current_path | trim_start_matches(pat=langpath) | split(pat="/page/") | slice(end=1) | join(sep="") | trim_end_matches(pat="/") %} + {%- set sec = sec ~ "/" %} + {%- endif %} + {%- if lang == config.default_language %} - {%- set section_item = get_section(path="_index.md") %} + {%- set section_item = get_section(path=sec ~ "_index.md") %} {%- else %} - {%- set section_item = get_section(path="_index." ~ lang ~ ".md") %} + {%- set section_item = get_section(path=sec ~ "_index." ~ lang ~ ".md") %} {%- endif %} <div> + {%- if section_item.title %} + <h2>{{ section_item.title }}</h2> + {%- endif %} {%- for year, posts in section_item.pages | group_by(attribute="year") %} - <h2>{{ year }}</h2> + {%- if section_item.title %}<h3>{{ year }}</h3>{%- else %}<h2>{{ year }}</h2>{%- endif %} {%- for post in posts %} <p><a href="{{ post.permalink | safe }}{%- if config.extra.uglyurls %}index.html{%- endif %}">{{ post.title }}</a> - <time datetime="{{ post.date }}">{{ post.date | date(format="%F") }}</time></p> {%- endfor %} |
