The goal of this change is to deduplicate all custom templates that are in use for taxonomy pages.
This commit defines the entrypoint for any taxonomy list page to be the 'layouts/taxonomy.html' template,
and removes all taxonomy-specific templates (e.g. 'layouts/publications/taxonomy.html'). Per-taxonomy
page customization are now handled via new partials and with front matter configuration via 'params'.
Any given taxonomy list page can now be customized to do the following:
- show all terms vs only terms that have a metadata-generated '_index.md' page (via '.Params.title')
- list items in a grid vs list items vertically
- include vs exclude filtering functionality (inclusion assumes the vertical list layout)
- specify which filter fields to use (e.g. 'kind', 'topic', 'year'), if filtering functionality is active
- specify which fields to include in the text search functionality, if filtering functionality is active
Customization happens in the '_index.md' page of any given taxonomy content directory.
For example 'content/publications/_index.md':
---
title: Publications
params:
list_variant: vertical # grid (default) | vertical (if filter == true, list_variant is set to vertical)
items: generated # generated (default) | all
filter: true # false (default) | true
filter_fields: # no default
- kind
- topic
- year
search_fields: # default: kind, topic, year, author, title
- kind
- topic
- year
- author
- title
---
And partials are then rendered based on this configuration.
Main configuration introduced with this commit:
- persons: grid view (default)
- objectives: grid view (default)
- projects: grid view (default)
- publications: filter view
- datasets: filter view
- instruments: filter view
The main repo README is updated with a description of this configuration and template pattern
TODO:
- add some partials for the parts that are displayed on a list item (e.g. the list of authors, the topics,
the icon-links, etc); and perhaps also configuration variables for their inclusion/exclusion
- Improved logic for selecting depictions; the current depiction registration workflow registers files
with names derived from the depiction kind, e.g. 'logo.png' or 'portrait.webp'. These are generally for
different purposes, and the logic might want to prefer a specific kind for a specific taxonomy, e.g.
'portrait' for 'persons', or 'logo' for 'instrument'.
- Update filtering-related code to make better use of hugo templating functionality; some aspects are still
hardcoded, e.g. 'data-*' for setting the list-item data values.
- Apply similar improvements to the 'term.html' template as done above for 'taxonomy.html'
111 lines
No EOL
4.7 KiB
HTML
111 lines
No EOL
4.7 KiB
HTML
<article
|
|
class="{{.Data.Singular }} px-3 mb-6 border rounded-md border-neutral-200 dark:border-neutral-700"
|
|
data-kind='{{ if .Params.kind}}{{ .Params.kind }}{{ else }}unknown{{ end }}'
|
|
data-year="{{ if .Params.date }}{{ substr .Params.date 0 4 }}{{ else }}unknown{{ end }}"
|
|
data-topic='{{ .Params.topic | jsonify }}'
|
|
data-author='{{ .Params.author | jsonify }}'
|
|
data-title="{{ .Title | lower }}"
|
|
>
|
|
|
|
{{ $depictions := .Resources.Match "depiction.*" }}
|
|
{{ $hasDepiction := gt (len $depictions) 0 }}
|
|
|
|
<table class="w-full m-0">
|
|
<tr>
|
|
<td class="align-middle">
|
|
<!-- Title, including year and DOI and publication kind -->
|
|
<h3 class="text-xl font-semibold text-neutral-900 dark:text-neutral-100" style="margin-top: 0;">
|
|
<a href="{{ .RelPermalink }}" style="text-decoration: unset;">
|
|
{{ .Title }}
|
|
</a>
|
|
{{ if .Params.date }}
|
|
{{ $year := substr .Params.date 0 4 }}
|
|
<span class="text-neutral-500 text-base font-normal">
|
|
({{ $year }})
|
|
</span>
|
|
{{ end }}
|
|
{{ with .Params.doi }}
|
|
<span class="mt-3 text-sm" style="border-left: 1px solid grey; padding-left: 0.5em;">
|
|
<a
|
|
href="https://doi.org/{{ . }}"
|
|
target="_blank"
|
|
class="text-primary-600"
|
|
style="text-decoration: unset;"
|
|
>
|
|
DOI: {{ . }}
|
|
</a>
|
|
</span>
|
|
{{ end }}
|
|
{{ with .Params.kind }}
|
|
<span class="mt-3 text-sm" style="font-style: italic; border-left: 1px solid grey; padding-left: 0.5em; margin-left: 0.5em;">
|
|
{{ . | replaceRE "^.*:" "" }}
|
|
</span>
|
|
{{ end }}
|
|
{{ if or .Params.source_code_url .Params.documentation_url}}
|
|
<span class="mt-3 text-xs" style="font-style: italic; border-left: 1px solid grey; padding-left: 0.5em; margin-left: 0.5em;"></span>
|
|
{{ with .Params.source_code_url }}
|
|
<a style="text-decoration: none; cursor:pointer;" target="_blank" href="{{ . }}" title="Source code">{{ partial "icon.html" "mdi-code-not-equal-variant"}}</a>
|
|
{{ end }}
|
|
{{ with .Params.documentation_url }}
|
|
<a style="text-decoration: none; cursor:pointer;" target="_blank" href="{{ . }}" title="Documentation">{{ partial "icon.html" "mdi-file-document"}}</a>
|
|
{{ end }}
|
|
{{ end }}
|
|
</h3>
|
|
|
|
<!-- Authors -->
|
|
{{ with .Params.author }}
|
|
<div class="mt-2 flex flex-wrap gap-1">
|
|
{{ range $i, $a := . }}
|
|
<span class="text-sm px-2 py-1 rounded-full border border-neutral-200 dark:border-neutral-700 whitespace-nowrap">
|
|
{{ $a.given_name }} {{ $a.family_name }}
|
|
</span>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
|
|
<!-- Topics -->
|
|
{{ with .Params.topic }}
|
|
<div class="flex flex-wrap gap-1" style="margin-top: 1em;">
|
|
<span class="ms-1 border-primary-400 px-1 py-[1px] text-xs font-normal dark:border-primary-600">
|
|
<em>Topics:</em>
|
|
</span>
|
|
{{ range . }}
|
|
<span
|
|
class="topic-chip ms-1 rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-secondary-700 dark:border-primary-600 dark:text-secondary-400"
|
|
data-topic="{{ .display_label }}"
|
|
>
|
|
<a style="text-decoration: none;">{{ .display_label }}</a>
|
|
</span>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
|
|
<!-- Licenses -->
|
|
{{ with .Params.license }}
|
|
<div class="mb-2 flex flex-wrap gap-1" style="margin-top: 1em;">
|
|
<span class="ms-1 border-primary-400 px-1 py-[1px] text-xs font-normal dark:border-primary-600">
|
|
<em>License:</em>
|
|
</span>
|
|
{{ range . }}
|
|
<span class="ms-1 rounded-md border border-primary-400 px-1 py-[1px] text-xs font-normal text-secondary-700 dark:border-primary-600 dark:text-secondary-400">
|
|
<a style="text-decoration: none;" target="_blank" href="{{ .url }}">{{ .label }}</a>
|
|
</span>
|
|
{{ end }}
|
|
</div>
|
|
{{ end }}
|
|
</td>
|
|
{{ if $hasDepiction }}
|
|
<td width="20%" class="align-middle text-center border-l-1 border-neutral-200 dark:border-neutral-700">
|
|
{{ with index $depictions 0 }}
|
|
{{ if eq .MediaType.SubType "svg" }}
|
|
<img src="{{ .RelPermalink }}" style="margin: 0;" alt="depiction of instrumet">
|
|
{{ else }}
|
|
<img src="{{ (.Fill "300x300 Center").RelPermalink }}" alt="depiction of instrumet">
|
|
{{ end }}
|
|
{{ end }}
|
|
</td>
|
|
{{ end }}
|
|
</tr>
|
|
</table>
|
|
|
|
</article> |