hugo without theme

This commit is contained in:
2020-10-13 21:44:56 +02:00
parent 611cdec8bd
commit a406d6a66e
723 changed files with 1253 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
{{/*
GetHeaderImage
This partial gets the resource for the header image for a given page.
If a header_image was set in the page's front matter, then that will be used.
If not set, this will search page resources to find an image that contains the word
"cover", and if found, returns the path to that resource.
If no header_image was set, and there's no "cover" image in page resources, then
this partial returns an empty string (which evaluates to false).
@return Resource of header image, or an empty string if not found.
*/}}
{{ $headerImage := "" }}
{{/* Defined as params */}}
{{ if isset .context.Params .name }}
{{ $image_name := .context.Param .name }}
{{ with .context.Resources.GetMatch $image_name }}
{{ $headerImage = . }}
{{ end }}
{{ end }}
{{/* Defined as resource */}}
{{ if $headerImage }}
{{ else }}
{{ if .context.Resources.GetMatch .name }}
{{ $img := .context.Resources.GetMatch .name }}
{{ with $img }}
{{ $headerImage = . }}
{{ end }}
{{/* Find the first image with 'cover' in the name in this page bundle. */}}
{{ else }}
{{ $img := (.context.Resources.ByType "image").GetMatch "*cover*" }}
{{ with $img }}
{{ $headerImage = . }}
{{ end }}
{{ end }}
{{ end }}
{{/* return either a Resource, or an empty string. Note that partials can only have a single
return statement, so this needs to be at the end of the partial (and not in the if block) */}}
{{ return $headerImage }}