fix: fix isPage detection for metatdata tags (#348)

This commit is contained in:
Robert Kaussow 2022-02-18 14:03:19 +01:00 committed by GitHub
parent 928906b251
commit 2ecb63e7b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 5 deletions

View File

@ -1,4 +1,6 @@
{{- if not (eq .Kind "home") }}
{{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
{{- if ne .Kind "home" }}
<meta
property="og:title"
{{ partial "utils/title" . | printf "content=%q" | safeHTMLAttr }}
@ -13,7 +15,7 @@
{{- with partial "utils/description" . }}
<meta property="og:description" content="{{ . | plainify | htmlUnescape | chomp }}" />
{{- end }}
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:type" content="{{ if $isPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
{{- with .Params.audio }}
<meta property="og:audio" content="{{ . }}" />
@ -43,7 +45,7 @@
{{- end }}
{{- end }}
{{ if .IsPage -}}
{{ if $isPage -}}
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section | humanize | title }}" />
{{- with .PublishDate }}

View File

@ -1,3 +1,4 @@
{{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
{{- if eq .Kind "home" }}
<script type="application/ld+json">
{
@ -17,7 +18,7 @@
"inLanguage": {{ .Lang }}
}
</script>
{{- else if or (and (not (eq .Type "posts")) (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
{{- else if $isPage }}
<script type="application/ld+json">
{
"@context": "http://schema.org",

View File

@ -1,9 +1,10 @@
{{ $isPage := or (and (ne .Type "posts") (in "section page" .Kind )) (and (eq .Type "posts") (eq .Kind "page")) }}
{{ $description := "" }}
{{ if .Description }}
{{ $description = .Description }}
{{ else }}
{{ if .IsPage }}
{{ if $isPage }}
{{ $description = .Summary }}
{{ else if .Site.Params.description }}
{{ $description = .Site.Params.description }}