From 3af6d9131f6dfc138856d718ec96626344095ec8 Mon Sep 17 00:00:00 2001 From: Jieiku Date: Mon, 22 May 2023 23:24:44 -0700 Subject: Optimizations and Fixes --- templates/posts.html | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'templates/posts.html') 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 %}