Skip to content

Commit

Permalink
fix: fix isPage detection for metatdata tags (#348)
Browse files Browse the repository at this point in the history
  • Loading branch information
xoxys authored Feb 18, 2022
1 parent 928906b commit 2ecb63e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
8 changes: 5 additions & 3 deletions layouts/partials/microformats/opengraph.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand All @@ -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="{{ . }}" />
Expand Down Expand Up @@ -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 }}
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/microformats/schema.html
Original file line number Diff line number Diff line change
@@ -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">
{
Expand All @@ -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",
Expand Down
3 changes: 2 additions & 1 deletion layouts/partials/utils/description.html
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down

0 comments on commit 2ecb63e

Please sign in to comment.