diff --git a/theme/templates/base.html b/theme/templates/base.html index aa8f26311b72a3f8c57b798d21bfcef86e274d06..0c78d03e3b598277f6a97beaf4ce0d8ac2459d2d 100644 --- a/theme/templates/base.html +++ b/theme/templates/base.html @@ -19,6 +19,14 @@ Hurra!!! lang ist definiert als {{ lang }}. {%- endif -%} {%- endmacro -%} +{%- macro tag_by_name(tagname) -%} + {%- for nativetag, tagarticles in tags -%} + {%- if nativetag.name == tagname -%} + {{- caller(nativetag, tagarticles) -}} + {%- endif -%} + {%- endfor -%} +{%- endmacro -%} + {%- macro article_by_slug(slug, lang) -%} {%- for a in all_articles -%} {%- if a.slug == slug and a.lang == lang -%} diff --git a/theme/templates/index.html b/theme/templates/index.html index 25de6adda54c4f903c09073e601a163552d9f0f2..fc10cff3d41aad5701ca2fc6601ee7268da551b5 100644 --- a/theme/templates/index.html +++ b/theme/templates/index.html @@ -42,6 +42,25 @@ {%- endcall -%} {%- endmacro -%} +{%- macro render_section_tag(s) -%} + {%- call(nativetag, tagarticles) tag_by_name(s.tag) -%} + {%- if s.title is not defined -%} + <header> + <h2 {% if s.id is defined -%}id="{{ s.id }}"{%- endif %}>{{ s.tag|e }}</h2> + </header> + {%- endif -%} + <ul class="catcards"> + {%- for article in tagarticles -%} + {%- if loop.index < s.num -%} + {%- call(nativecat, sccat, _) category_by_name(article.category.name) -%} + <li style="--category-color: {{ sccat.color }}"><a href="{{ SITEURL }}/{{ article.url }}">{{ article.title }}</a></li> + {%- endcall -%} + {%- endif -%} + {%- endfor -%} + </ul> + {%- endcall -%} +{%- endmacro -%} + {%- macro render_section(s) -%} {%- if s.title is defined -%} <header> @@ -56,6 +75,8 @@ {{ render_section_custom(s) }} {%- elif s.type == "category" -%} {{ render_section_category(s) }} + {%- elif s.type == "tag" -%} + {{ render_section_tag(s) }} {%- else -%} <br /> <strong>ERROR: render_section: Unknown section type: {{ s.type|e }}</strong><br /> diff --git a/theme/templates/tag.html b/theme/templates/tag.html new file mode 100644 index 0000000000000000000000000000000000000000..551bb5b0c6f3b183213dcaed3f50ff760e2cc40c --- /dev/null +++ b/theme/templates/tag.html @@ -0,0 +1,7 @@ +{% extends "index.html" %} +{% block title %}{{ l[lang].title_prefix }}{{ l[lang].sitename }}{{ l[lang].title_suffix }} - {{ tag }}{%endblock%} +{% block content %} + <section> + {{ render_section({"type": "tag", "tag": tag.slug, "num": 5000 }) }} + </section> +{% endblock content %}