2019-01-08 17:33:28 +01:00
{{- /*
Usage: `placeholder args`
2021-01-16 20:51:12 +01:00
`args` are all optional and can be one of the following:
* title: Used in the SVG `title` tag - default: "Placeholder"
* text: The text to show in the image - default: "width x height"
* class: Class to add to the `svg` - default: "bd-placeholder-img"
* color: The text color (foreground) - default: "#dee2e6"
* background: The background color - default: "#868e96"
* width: default: "100%"
* height: default: "180px"
2019-01-08 17:33:28 +01:00
*/ -}}
{{- $grays := $.Site.Data.grays -}}
2021-01-16 20:51:12 +01:00
{{- $default_color := (index $grays 2).hex -}}
{{- $default_background := (index $grays 5).hex -}}
2019-01-08 17:33:28 +01:00
{{- $title := .Get "title" | default "Placeholder" -}}
{{- $class := .Get "class" -}}
2021-01-16 20:51:12 +01:00
{{- $color := .Get "color" | default $default_color -}}
{{- $background := .Get "background" | default $default_background -}}
2019-01-08 17:33:28 +01:00
{{- $width := .Get "width" | default "100%" -}}
{{- $height := .Get "height" | default "180" -}}
{{- $text := .Get "text" | default (printf "%sx%s" $width $height) -}}
{{- $show_title := not (eq $title "false") -}}
{{- $show_text := not (eq $text "false") -}}
2020-09-04 19:21:54 +02:00
< svg class = "bd-placeholder-img{{ with $class }} {{ . }}{{ end }}" width = "{{ $width }}" height = "{{ $height }}" xmlns = "http://www.w3.org/2000/svg" { { if ( or $ show_title $ show_text ) } } role = "img" aria-label = "{{ if $show_title }}{{ $title }}{{ if $show_text }}: {{ end }}{{ end }}{{ if ($show_text) }}{{ $text }}{{ end }}" { { else } } aria-hidden = "true" { { end } } preserveAspectRatio = "xMidYMid slice" focusable = "false" >
2021-01-16 20:51:12 +01:00
{{- if $show_title }}< title > {{ $title }}< / title > {{ end -}}
2019-01-08 17:33:28 +01:00
< rect width = "100%" height = "100%" fill = "{{ $background }}" / >
2021-01-16 20:51:12 +01:00
{{- if $show_text }}< text x = "50%" y = "50%" fill = "{{ $color }}" dy = ".3em" > {{ $text }}< / text > {{ end -}}
2019-01-08 17:33:28 +01:00
< / svg >