Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/alanorth/hugo-theme-bootstrap4-blog.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Orth <alan.orth@gmail.com>2020-12-04 15:09:27 +0300
committerAlan Orth <alan.orth@gmail.com>2020-12-04 15:09:27 +0300
commit54f85c3bebeffbe6305a7f9e013b98d7840ab592 (patch)
treeafd6fd38d5a65b96628782a3baa48a225d53a52d
parentc6498a4bfbc82474e485c456ae3d414d54f4e9f7 (diff)
layouts/_default/single.html: Fix for images in the page bundle
-rw-r--r--layouts/_default/single.html20
1 files changed, 15 insertions, 5 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index b144e33..d069ecc 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -7,18 +7,28 @@
"@type": "BlogPosting",
{{- /* Google recommends the headline be no more than 110 characters */}}
"headline": {{ substr .Title 0 110 }},
- {{- with .Params.images -}}{{ range first 1 . }}
+ {{- with .Params.images -}}{{- range first 1 . -}}
+ {{/* try to get the image from the page bundle */}}
+ {{- with $.Page.Resources.GetMatch (printf "*%s*" .) }}
"image": {
"@type": "ImageObject",
- "url": {{ . | absURL }}
+ "url": {{ .Permalink }},
+ "height": "{{ .Height }}",
+ "width": "{{ .Width }}"
+ {{/* otherwise, get the image from static */}}
+ {{- else }}
+ "image": {
+ "@type": "ImageObject",
+ {{- $image := . -}}
{{- /* Don't try to get imageConfig if image param is not local */ -}}
{{- if not (or (hasPrefix . "http://") (hasPrefix . "https://")) -}}
- {{- with (imageConfig (printf "/static/%s" .)) -}}
- ,
+ {{- with (imageConfig (printf "/static/%s" .)) }}
+ "url": {{ $image | absURL }},
"height": "{{ .Height }}",
"width": "{{ .Width }}"
{{- end -}}
- {{ end }}
+ {{- end -}}
+ {{ end }}
},
{{- end -}}{{ end }}
"url": {{ printf "%s" .Permalink }},