From e55841149d9259f26f4d117daba34b5666a52097 Mon Sep 17 00:00:00 2001 From: Benedikt Peetz Date: Fri, 11 Sep 2026 22:02:29 +0200 Subject: src/themes/serene: Update to newest version --- .../serene/templates/_components/collection.html | 129 +++++++++++++++++++++ 1 file changed, 129 insertions(+) create mode 100644 src/themes/serene/templates/_components/collection.html (limited to 'src/themes/serene/templates/_components/collection.html') diff --git a/src/themes/serene/templates/_components/collection.html b/src/themes/serene/templates/_components/collection.html new file mode 100644 index 0000000..70a1d31 --- /dev/null +++ b/src/themes/serene/templates/_components/collection.html @@ -0,0 +1,129 @@ +{# + This component is used inside markdown content, which is rendered as a Tera + template first and *then* processed as markdown (zola >= 0.23). Its HTML + output must therefore stay markdown-safe: no blank lines in the middle of + an HTML block, and no lines indented by 4+ spaces. + + Collection file schema: + layout = "card" | "row" | "tile" | "gallery" (default "card") + flow = "stack" | "inline" | "grid" (default: card/gallery -> "stack", row/tile -> "inline") + [[item]] + title / subtitle / content / icon / image / link / badge / tags / featured / rotate +#} + +{% component collection(file: string, section) -%} +{%- set data = load_data(path="content" ~ section.path ~ file, format="toml") -%} +{%- set layout = data.layout if data.layout is defined else "card" -%} +{%- if layout not in ["card", "row", "tile", "gallery"] -%} +{%- set layout = "card" -%} +{%- endif -%} +{%- if data.flow is defined and data.flow in ["stack", "inline", "grid"] -%} +{%- set flow = data.flow -%} +{%- elif layout == "row" or layout == "tile" -%} +{%- set flow = "inline" -%} +{%- else -%} +{%- set flow = "stack" -%} +{%- endif -%} +{%- if layout == "card" and flow == "inline" -%} +{%- set flow = "grid" -%} +{%- endif -%} +
+{%- for item in data.item -%} +{%- set img_src = "" -%} +{%- if item.image is defined -%} +{%- if item.image is starting_with(pat="http") or item.image is starting_with(pat="/") or item.image is starting_with(pat="data:") -%} +{%- set img_src = item.image -%} +{%- else -%} +{%- set img_src = get_url(path=section.colocated_path ~ item.image) -%} +{%- endif -%} +{%- endif -%} +{%- set icon_src = "" -%} +{%- if item.icon is defined -%} +{%- if item.icon is starting_with(pat="http") or item.icon is starting_with(pat="/") or item.icon is starting_with(pat="data:") -%} +{%- set icon_src = item.icon -%} +{%- else -%} +{%- set icon_src = get_url(path=section.colocated_path ~ item.icon) -%} +{%- endif -%} +{%- endif -%} +{%- set external = item.link is defined and not item.link is starting_with(pat="/") -%} +{%- if layout == "card" -%} +
+{%- if img_src -%}
{{ item.title }}
{%- endif -%} +
+
+{%- if icon_src -%}{%- endif -%} +{%- if item.link -%} +{{ item.title }} +{%- else -%} +{{ item.title }} +{%- endif -%} +{%- if item.badge -%}{{ item.badge }}{%- endif -%} +
+{%- if item.subtitle -%} +
{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}
+{%- endif -%} +{%- if item.content -%} +
+{{ item.content | trim | markdown | trim | safe }} +
+{%- endif -%} +{%- if item.tags -%} +
+{%- for tag in item.tags -%} +#{{ tag }} +{%- endfor -%} +
+{%- endif -%} +
+
+{%- elif layout == "row" -%} + + +{%- if icon_src -%}{%- endif -%} +{%- if item.link -%} +{{ item.title }} +{%- else -%} +{{ item.title }} +{%- endif -%} + +{%- if item.subtitle -%}{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}{%- endif -%} +{%- if item.badge -%}{{ item.badge }}{%- endif -%} + +{%- elif layout == "tile" -%} +{%- if item.link -%} + +{%- else -%} + +{%- endif -%} + +{{ item.title }} +{%- if item.subtitle -%}{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}{%- endif -%} + +{%- if img_src -%} +{{ item.title }} +{%- else -%} + +{%- endif -%} +{%- if item.link -%}{%- else -%}{%- endif -%} +{%- elif layout == "gallery" -%} +
+{%- if img_src -%}
{{ item.title }}
{%- endif -%} +
+{%- if item.link -%} +{{ item.title }} +{%- else -%} +{{ item.title }} +{%- endif -%} +{%- if item.subtitle -%}{{ item.subtitle | trim | markdown(inline=true) | trim | safe }}{%- endif -%} +{%- if item.content -%} +
+{{ item.content | trim | markdown | trim | safe }} +
+{%- endif -%} +{%- if item.badge -%}{{ item.badge }}{%- endif -%} +
+
+{%- endif -%} +{%- endfor -%} +
+{%- endcomponent collection %} -- cgit v1.3.1