bobatheme/layouts/partials/opengraph.html

49 lines
1.6 KiB
HTML
Raw Normal View History

2021-11-20 18:24:56 -06:00
<meta property="og:title" content="{{ .Title }}">
2021-11-20 18:30:26 -06:00
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ if .IsPage }}{{ .Summary | plainify }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}">
2021-11-20 18:24:56 -06:00
<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 }}