bobatheme/layouts/partials/seo-tags/opengraph.html

49 lines
1.5 KiB
HTML

<meta property="og:title" content="{{ .Title | plainify }}">
<meta property="og:description" content="{{ (partial "seo-description.html" .) | plainify }}">
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}">
<meta property="og:url" content="{{ .Permalink }}">
{{ $images := $.Resources.ByType "image" }}
{{ $featured := $images.GetMatch "*feature*" }}
{{ if not $featured }}
{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }}
{{ with $featured }}
<meta property="og:image" content="{{ $featured.Permalink }}">
{{ end }}
{{ with .Section }}
<meta property="article:section" content="{{ . }}">
{{ end }}
{{ $format := "2006-01-02T15:04:05-07:00" }}
{{ with .Date }}
<meta property="article:published_time" content="{{ .Format $format }}">
{{ end }}
{{ with .Lastmod }}
<meta property="article:modified_time" {{ .Format $format | printf "content=%q" | safeHTMLAttr }}>
{{ end }}
{{ with .Params.audio }}
<meta property="og:audio" content="{{ . }}">
{{ end }}
{{ with .Language.Lang }}
<meta property="og:locale" content="{{ . }}">
{{ end }}
{{ with .Site.Params.title }}
<meta property="og:site_name" content="{{ . }}">
{{ end }}
{{ $videos := $.Resources.ByType "video" }}
{{ $featured_video := $videos.GetMatch "*feature*" }}
{{ if not $featured_video }}
{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}
{{ end }}
{{ with $featured_video }}
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}">
{{ end }}