rimarima/themes/hugo-liftoff/layouts/partials/head/seo/opengraph.html
Adrian Amaglio c09f092db4 init
2023-11-17 10:54:41 +01:00

72 lines
3.2 KiB
HTML

<meta property="og:locale" content="{{ .Site.Params.ogLocale }}">
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:title" content="{{- with .Params.seo_title -}}{{- . -}}{{ else }}{{- .Title -}}{{ end }}{{ if (or (and (ne .Type "posts") (ne .Type "projects") (not .IsHome)) (and (not .IsPage) (not .IsHome))) }} | {{ .Site.Title -}}{{ end -}}">
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
{{ if $.Scratch.Get "paginator" -}}
{{ $paginator := .Paginate (where .Site.RegularPages.ByDate.Reverse "Section" "posts" ) -}}
<meta property="og:url" content="{{ .Paginator.URL | absURL }}">
{{ else -}}
<meta property="og:url" content="{{ .Permalink }}">
{{ end -}}
{{ with .Site.Params.title -}}
<meta property="og:site_name" content="{{ . }}">
{{ end -}}
{{ $iso8601 := "2006-01-02T15:04:05-07:00" -}}
{{ if .IsPage -}}
{{ if not .PublishDate.IsZero -}}
<meta property="article:published_time" {{ .PublishDate.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ else if not .Date.IsZero -}}
<meta property="article:published_time" {{ .Date.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end -}}
{{ if not .Lastmod.IsZero -}}
<meta property="article:modified_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end -}}
{{ else -}}
{{ if not .Date.IsZero -}}
<meta property="og:updated_time" {{ .Lastmod.Format $iso8601 | printf "content=%q" | safeHTMLAttr }}>
{{ end -}}
{{ end -}}
{{ $images := $.Resources.ByType "image" -}}
{{ $feature := $images.GetMatch "*feature*" -}}
{{ $feature_param := $.Params.feature_image }}
{{ $feature_frontmatter := $images.GetMatch $feature_param }}
{{ if $feature_frontmatter -}}
<meta property="og:image" content="{{ $feature_frontmatter.Permalink }}"/>
{{ with $.Params.feature_image_alt }}
<meta property="og:image:alt" content="{{ . }}" />
{{ end }}
{{ else if $feature -}}
<meta property="og:image" content="{{ $feature.Permalink }}"/>
{{ with $.Params.feature_image_alt }}
<meta property="og:image:alt" content="{{ . }}" />
{{ end }}
{{ else if $.Params.images }}
<meta name="og:image" content="{{ index $.Params.images 0 | absURL }}"/>
{{ else if $.Site.Params.images }}
<meta name="og:image" content="{{ index $.Site.Params.images 0 | absURL }}"/>
{{ end }}
{{ with .Params.audio -}}
<meta property="og:audio" content="{{ . | absURL }}">
{{ end -}}
{{ 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 }}
{{/* Only add property if taxonomy is enabled */}}
{{ if $siteSeries }}
{{ 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 }}