mirror of
https://github.com/alanorth/hugo-theme-bootstrap4-blog.git
synced 2024-12-19 00:52:19 +01:00
layouts/_default/single.html: Fix for images in the page bundle
This commit is contained in:
parent
c6498a4bfb
commit
54f85c3beb
@ -7,16 +7,26 @@
|
|||||||
"@type": "BlogPosting",
|
"@type": "BlogPosting",
|
||||||
{{- /* Google recommends the headline be no more than 110 characters */}}
|
{{- /* Google recommends the headline be no more than 110 characters */}}
|
||||||
"headline": {{ substr .Title 0 110 }},
|
"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": {
|
"image": {
|
||||||
"@type": "ImageObject",
|
"@type": "ImageObject",
|
||||||
"url": {{ . | absURL }}
|
"url": {{ .Permalink }},
|
||||||
{{- /* Don't try to get imageConfig if image param is not local */ -}}
|
|
||||||
{{- if not (or (hasPrefix . "http://") (hasPrefix . "https://")) -}}
|
|
||||||
{{- with (imageConfig (printf "/static/%s" .)) -}}
|
|
||||||
,
|
|
||||||
"height": "{{ .Height }}",
|
"height": "{{ .Height }}",
|
||||||
"width": "{{ .Width }}"
|
"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" .)) }}
|
||||||
|
"url": {{ $image | absURL }},
|
||||||
|
"height": "{{ .Height }}",
|
||||||
|
"width": "{{ .Width }}"
|
||||||
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user