7
1
mirror of https://gitlab.com/ansol/web-ansol.org.git synced 2024-12-24 12:55:44 +00:00
web-ansol.org/themes/academic/layouts/partials/functions/get_logo.html
2020-06-11 12:46:16 +01:00

22 lines
981 B
HTML

{{/* Function to get logo image. */}}
{{/* Inputs: constraint: max_height/fit (str); size (int) */}}
{{/* Output: resource (obj) */}}
{{/* Workaround fact Hugo does not support GetMatch in assets dir */}}
{{/* Hugo doesn't support image ops on SVG: https://discourse.gohugo.io/t/ho-do-i-convert-a-generic-resource-to-image-resource/22570/4 */}}
{{ $logo := resources.Get "images/logo.png" | default (resources.Get "images/logo.svg") }}
{{ $logo_proc := $logo }}
{{/* If the type of image can be resized by Hugo, resize it given a `.size` argument to the function. */}}
{{ if resources.Get "images/logo.png" }}
{{ if eq .constraint "max_height" }}
{{/* Resize logo to fit specified max height. */}}
{{ $logo_proc = ($logo.Resize (printf "x%s" (string .size))) }}
{{ else }}
{{/* Constrain logo to fit within specified dimensions. */}}
{{ $logo_proc = ($logo.Fit (printf "%sx%s" (string .size) (string .size))) }}
{{ end }}
{{ end }}
{{ return $logo_proc }}