mirror of
https://github.com/BBaoVanC/bobatheme.git
synced 2025-08-11 09:41:36 -05:00
Support opengraph structured properties on image and video
This commit is contained in:
@@ -3,16 +3,6 @@
|
|||||||
<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 }}">
|
<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 }}
|
{{ with .Section }}
|
||||||
<meta property="article:section" content="{{ . }}">
|
<meta property="article:section" content="{{ . }}">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
@@ -37,12 +27,38 @@
|
|||||||
<meta property="og:site_name" content="{{ . }}">
|
<meta property="og:site_name" content="{{ . }}">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
{{ $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 }}">
|
||||||
|
{{ with .Params.alt }}
|
||||||
|
<meta property="og:image:alt" content="{{ . }}">
|
||||||
|
{{ end }}
|
||||||
|
{{ with .MediaType }}
|
||||||
|
<meta property="og:image:type" content="{{ . }}">
|
||||||
|
{{ end }}
|
||||||
|
{{ with .Width }}
|
||||||
|
<meta property="og:image:width" content="{{ . }}">
|
||||||
|
{{ end }}
|
||||||
|
{{ with .Height }}
|
||||||
|
<meta property="og:image:height" content="{{ . }}">
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ $videos := $.Resources.ByType "video" }}
|
{{ $videos := $.Resources.ByType "video" }}
|
||||||
{{ $featured_video := $videos.GetMatch "*feature*" }}
|
{{ $featured_video := $videos.GetMatch "*feature*" }}
|
||||||
{{ if not $featured_video }}
|
{{ if not $featured_video }}
|
||||||
{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}
|
{{ $featured_video = $videos.GetMatch "{*cover*,*thumbnail*}" }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
|
|
||||||
{{ with $featured_video }}
|
{{ with $featured_video }}
|
||||||
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}">
|
<meta property="og:video" content="{{ $featured_video.Permalink | absURL }}">
|
||||||
|
{{ with .MediaType }}
|
||||||
|
<meta property="og:video:type" content="{{ . }}">
|
||||||
|
{{ end }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
Reference in New Issue
Block a user