Files
hugo-academic-contact/layouts/partials/academic-contact.html
2026-02-10 08:27:07 +01:00

64 lines
2.4 KiB
HTML

{{/* Get the resource from the module's assets folder */}}
{{ $css := resources.Get "css/academic-contact.css" }}
{{/* Minify and Fingerprint for production */}}
{{ if hugo.IsProduction }}
{{ $css = $css | minify | fingerprint }}
{{ end }}
{{/* Output the link tag */}}
<link rel="stylesheet" href="{{ $css.RelPermalink }}" {{ if hugo.IsProduction }}integrity="{{ $css.Data.Integrity }}"{{ end }}>
<div class="academic-contact">
{{ range sort (index .Site.Data.academic_contact) "weight" "asc" }}
<span class="academic-contact-entry">
{{/* Removing link for location */}}
{{ if not (in .type "location") }}
{{/* Building link for each type */}}
{{/* Initialize the variable */}}
{{ $baselink := "" }}
{{ if eq .type "email" }}
{{ $baselink = "mailto:" }}
{{ end }}
{{ if eq .type "orcid" }}
{{ $baselink = "https://orcid.org/" }} {{/* Note: ORCID usually uses .org */}}
{{ end }}
{{ if eq .type "scholar" }}
{{ $baselink = "https://scholar.google.com/citations?user=" }}
{{ end }}
{{ if eq .type "github" }}
{{ $baselink = "https://github.com/" }}
{{ end }}
<a href="{{ $baselink }}{{ .value }}" target="_blank" rel="noopener">
{{ end }}
{{/* Capture the icon type for image name */}}
{{ $imageName := .type }}
{{/* Construct the match pattern string */}}
{{ $pattern := printf "icons/%s*" $imageName }}
{{/* Use the pattern to get the resource */}}
{{ $image := resources.GetMatch $pattern }}
{{ with $image }}
{{/* Use .RelPermalink to get the actual dynamic URL */}}
<img src="{{ .RelPermalink }}" alt="{{ $imageName }} icon" class="academic-contact-icon"/>
{{ end }}
{{ if in .type "location" }}
<span class="academic-contact-value">{{ .value }}</span>
{{ else }}
<span class="academic-contact-value">{{ .type | humanize }}</span>
{{ end }}
{{ if not (in .type "location") }}
</a>
{{ end}}
</span>
{{ end }}
</div>