PaperModX/layouts/partials/templates/opengraph.html

46 lines
2.0 KiB
HTML
Raw Normal View History

2022-05-05 11:47:00 +01:00
{{ with .page }}
<meta property="og:title" content="{{ $.pageTitle }}" />
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
{{- if .Params.cover.image -}}
2022-05-08 15:42:23 +01:00
{{- if (eq .Params.cover.absolute true) }}
<meta property="og:image" content="{{ .Params.cover.image | absURL }}" />
{{- else}}
<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
{{- end}}
{{- else }}
2022-05-08 15:42:23 +01:00
{{- range site.Params.images }}
<meta property="og:image" content="{{ . | absURL }}"/>
{{- end }}
{{ end }}
{{- if .IsPage }}
2022-05-08 15:42:23 +01:00
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
<meta property="article:section" content="{{ .Section }}" />
{{ with .PublishDate }}<meta property="article:published_time" content="{{ .Format $iso8601 }}" />{{ end }}
{{ with .Lastmod }}<meta property="article:modified_time" content="{{ .Format $iso8601 }}" />{{ end }}
{{- end -}}
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
{{- with site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
2022-05-08 15:42:23 +01:00
{{- with .Params.videos }}
{{- range . }}
<meta property="og:video" content="{{ . | absURL }}" />
{{- end }}
{{- end }}
{{- /* If it is part of a series, link to related articles */}}
{{- $permalink := .Permalink }}
{{- $siteSeries := site.Taxonomies.series }}
2022-05-08 15:42:23 +01:00
{{- with .Params.series }}
{{- range $name := . }}
{{- $series := index $siteSeries ($name | urlize) }}
{{- range $page := first 6 $series.Pages }}
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}