hugo-theme-bootstrap5-blog/layouts/_default/single.html

81 lines
2.6 KiB
HTML

{{ define "title" }}{{ .Title | markdownify }} | {{ .Site.Title }}{{ end }}
{{ define "schema-dot-org" }}
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "BlogPosting",
{{- /* Google recommends the headline be no more than 110 characters */}}
"headline": {{ substr .Title 0 110 }},
{{- 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": {{ .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" .)) }}
"url": {{ $image | absURL }},
"height": "{{ .Height }}",
"width": "{{ .Width }}"
{{- end -}}
{{- end -}}
{{ end }}
},
{{- end -}}{{ end }}
"url": {{ printf "%s" .Permalink }},
"wordCount": "{{ .WordCount }}",
{{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
{{- if not .PublishDate.IsZero }}
"datePublished": {{ .PublishDate.Format $ISO8601 }},
{{- else }}
"datePublished": {{ .Date.Format $ISO8601 }},
{{- end }}
{{- if not .Lastmod.IsZero }}
"dateModified": {{ .Lastmod.Format $ISO8601 }},
{{- end }}
"author": {
"@type": "Person",
"name": {{ .Params.author | default .Site.Params.author }}
}
{{- if or (.Params.keywords) (or (.Params.categories) (.Params.tags)) -}}
,
"keywords": {{ delimit (union .Params.keywords (union .Params.categories .Params.tags)) ", " }}
{{- end }}
{{- with .Params.description -}}
,
"description": {{ . }}
{{- end }}
}
</script>
{{ end }}
{{ define "main" }}
{{ $dateFormat := default "Mon Jan 2, 2006" (index .Site.Params "date_format") }}
<div class="row">
<div class="col-md-8">
<article class="blog-post">
<h2 class="blog-post-title"><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h2>
<p class="blog-post-meta">{{ if not .PublishDate.IsZero }}<time {{ .Date.Format "2006-01-02T15:04:05Z07:00" | printf "datetime=%q" | safeHTMLAttr }}>{{ .Date.Format $dateFormat }}</time>{{ end }}
{{ if or (.Params.categories) (.Params.tags) }} in {{ partial "meta-terms.html" . }}{{ end }}</p>
{{ .Content }}
</article>{{ "<!-- /.blog-post -->" | safeHTML }}
</div>
{{ end }}
{{- /* vim: set ts=2 sw=2 et: */}}