From bedbe5733cd813bd5173c165998ceeefba17d348 Mon Sep 17 00:00:00 2001 From: Stephan Heunis Date: Thu, 19 Mar 2026 16:17:32 +0100 Subject: [PATCH] Use jinja for parameter injection and hugo template for person page This uses the new '__rec' property of 'query-things' 'render_record' command to extract values for explicitly defined keys and inject them under 'params' in the markdown page front matter. This makes them available to a hugo template under '.Params'. A new 'layouts/_default/person.html' template is now responsible for rendering everything on a person page. This allows using hugo's bundle resources to easily check e.g. if there is a portrait of the person in the bundle. The template renders everything that was previously rendered from the _index.md page, and will put the portrait and graph side by side if a portrait exists, otherwise the graph will display full-width. A snippet from the congo theme is included at the end of the template in order to render all taxonomy related terms. --- layouts/_default/person.html | 108 +++++++++++++++++++++++++++++++++++ page_templates/person.md.j2 | 21 +++---- 2 files changed, 116 insertions(+), 13 deletions(-) create mode 100644 layouts/_default/person.html diff --git a/layouts/_default/person.html b/layouts/_default/person.html new file mode 100644 index 0000000..107c83f --- /dev/null +++ b/layouts/_default/person.html @@ -0,0 +1,108 @@ +{{ define "main" }} +
+ {{ if .Params.showBreadcrumbs | default (.Site.Params.list.showBreadcrumbs | default false) }} + {{ partial "breadcrumbs.html" . }} + {{ end }} + {{ if and .Params.given_name .Params.family_name }} +

{{ .Params.given_name }} {{ .Params.family_name }}

+ {{ else }} +

{{ .Title }}

+ {{ end }} +
+
+ + {{ $portraits := .Resources.Match "portrait.*" }} + {{ $hasPortrait := gt (len $portraits) 0 }} + + + {{ if $hasPortrait }} + + {{ end }} + + +
+ {{ with index $portraits 0 }} + Portrait of {{ $.Params.given_name }} {{ $.Params.family_name }} + {{ end }} + + {{ if .Param "graphRootNodePID" | default false }} +
+ + +
+ {{ if .Param "graphDescription" | default false }} +

{{ .Param "graphDescription" }}

+ {{ end }} +
+
+
+
+
+
+ {{ end }} +
+ + {{ with .Params.description }} +

{{ . }}

+ {{ end }} + + {{ $links := dict + "Debian" "https://qa.debian.org/developer.php?login=%s" + "GitHub" "https://github.com/%s" + "LinkedIn" "https://www.linkedin.com/in/%s" + "ORCID" "https://orcid.org/%s" + "ResearchGate" "https://www.researchgate.net/profile/%s" + }} + {{ with .Params.identifiers }} + + {{ end }} +
+ {{ if .Data.Pages }} +
+
+ {{ if $.Params.groupByYear | default ($.Site.Params.list.groupByYear | default true) }} + {{ range (.Paginate (.Pages.GroupByDate "2006")).PageGroups }} +

+ {{ .Key }} +

+
+ {{ range .Pages }} + {{ partial "article-link.html" . }} + {{ end }} + {{ end }} + {{ else }} + {{ range (.Paginate .Pages).Pages }} + {{ partial "article-link.html" . }} + {{ end }} + {{ end }} +
+ {{ partial "pagination.html" . }} + {{ else }} +
+

+ {{ i18n "list.no_articles" | emojify }} +

+
+ {{ end }} +{{ end }} \ No newline at end of file diff --git a/page_templates/person.md.j2 b/page_templates/person.md.j2 index 8f6629e..4401e78 100644 --- a/page_templates/person.md.j2 +++ b/page_templates/person.md.j2 @@ -2,17 +2,12 @@ title: {{ given_name }} {{ family_name }} params: graphRootNodePID: {{ pid }} +{%- set fields = ["given_name", "family_name", "identifiers", "description"] %} +{%- set p = {} %} +{%- for f in fields %} + {%- if f in __rec and __rec[f] %} + {%- set _ = p.update({f: __rec[f]}) %} + {%- endif %} +{%- endfor %} + {{ p | toyaml | indent(2) | trim }} --- - -{{ description }} - -{%- for identifier in identifiers if identifier.creator.name is defined -%} -{%- if description is defined and loop.first %}{{ '\n\n' }}{% endif -%} -{% if identifier.creator.name == "Debian" %}- [Debian: {{ identifier.notation }}](https://qa.debian.org/developer.php?login={{ identifier.notation }}) -{% elif identifier.creator.name == "GitHub" %}- [GitHub: {{ identifier.notation }}](https://github.com/{{ identifier.notation }}) -{% elif identifier.creator.name == "LinkedIn" %}- [LinkedIn: {{ identifier.notation }}](https://www.linkedin.com/in/{{ identifier.notation }}) -{% elif identifier.creator.name == "ORCID" %}- [ORCID: {{ identifier.notation }}](https://orcid.org/{{ identifier.notation }}) -{% elif identifier.creator.name == "ResearchGate" %}- [ResearchGate: {{ identifier.notation }}](https://www.researchgate.net/profile/{{ identifier.notation }}) -{% else %}- {{ identifier.creator.name }}: {{ identifier.notation }} -{% endif %} -{%- endfor -%} -- 2.52.0