mirror of
https://github.com/imfing/hextra.git
synced 2025-06-19 08:24:06 -04:00
chore: adapt theme to new template system (#696)
* Adapted theme's layout to [Hugo v0.146.0](https://gohugo.io/templates/new-templatesystem-overview/) * Bumped minimal Hugo version to v0.146.0
This commit is contained in:
49
layouts/_shortcodes/card.html
Normal file
49
layouts/_shortcodes/card.html
Normal file
@ -0,0 +1,49 @@
|
||||
{{- $context := . -}}
|
||||
{{- $link := .Get "link" -}}
|
||||
{{- $title := .Get "title" -}}
|
||||
{{- $icon := .Get "icon" -}}
|
||||
{{- $subtitle := .Get "subtitle" -}}
|
||||
{{- $image := .Get "image" -}}
|
||||
{{- $width := 0 -}}
|
||||
{{- $height := 0 -}}
|
||||
{{- $imageStyle := .Get "imageStyle" -}}
|
||||
{{- $tag := .Get "tag" -}}
|
||||
{{- $tagType := .Get "tagType" -}}
|
||||
|
||||
{{/* Image processing options */}}
|
||||
{{- $method := .Get "method" | default "Resize" | humanize -}}
|
||||
{{- $options := .Get "options" | default "800x webp q80" -}}
|
||||
{{- $process := .Get "process" | default (printf "%s %s" $method $options) -}}
|
||||
|
||||
{{- if and $image (not (urls.Parse $image).Scheme) -}}
|
||||
{{- with or (.Page.Resources.Get $image) (resources.Get $image) -}}
|
||||
{{/* .Process does not work on svgs */}}
|
||||
{{- if (not (eq .MediaType.SubType "svg")) -}}
|
||||
{{/* Retrieve the $image resource from local or global resources */}}
|
||||
{{- $processed := .Process $process -}}
|
||||
{{- $width = $processed.Width -}}
|
||||
{{- $height = $processed.Height -}}
|
||||
{{- $image = $processed.RelPermalink -}}
|
||||
{{- end -}}
|
||||
{{ else }}
|
||||
{{/* Otherwise, use relative link of the image */}}
|
||||
{{- if hasPrefix $image "/" -}}
|
||||
{{- $image = relURL (strings.TrimPrefix "/" $image) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- partial "shortcodes/card" (dict
|
||||
"page" .Page
|
||||
"link" $link
|
||||
"title" $title
|
||||
"icon" $icon
|
||||
"subtitle" $subtitle
|
||||
"image" $image
|
||||
"width" $width
|
||||
"height" $height
|
||||
"imageStyle" $imageStyle
|
||||
"tag" $tag
|
||||
"tagType" $tagType
|
||||
)
|
||||
-}}
|
Reference in New Issue
Block a user