ADD open graph protocol support

This commit is contained in:
Hoernschen 2022-07-01 13:39:37 +02:00
parent 1007588f1a
commit 9d04415667
Signed by: hoernschen
GPG key ID: 37591FAF4E6D3462
3 changed files with 55 additions and 3 deletions

View file

@ -1,3 +1,35 @@
{{ define "opengraph" }}
<meta property="og:type" content="article" />
{{ with .Site.LanguageCode }}
<meta property="og:locale" content='{{ replace . "-" "_" }}' />
{{ end }}
<meta property="og:title" content="{{ if .Title }}{{ .Title }}{{ else }}{{ .Site.Title }}{{ end }}" />
<meta property="og:url" content="{{ .Permalink }}" />
<meta property="og:site_name" content="{{ .Site.Title }}" />
{{ if .Params.image }}
<meta property="og:image" content="{{ .Params.image | absURL }}" />
{{ else }}
<meta property="og:image" content="{{ .Site.Params.logo | absURL }}" />
{{ end }}
{{ if .Params.summary }}
<meta property="og:description" content="{{ .Params.summary }}" />
{{ else if .Content }}
<meta property="og:description" content="{{ .Content | safeHTML | truncate 100 }}" />
{{ else }}
<meta property="og:description" content="{{ .Site.Params.Description }}" />
{{ end }}
<meta property="article:published_time" content='{{.Date.Format "2006-01-02"}}' />
{{ with .Params.author }}
<meta property="article:author" content="{{ . }}" />
{{ end }}
<meta property="article:section" content="Blog" />
{{ with .Params.tags }}
{{ range . }}
<meta property="article:tag" content="{{ . }}" />
{{ end }}
{{ end }}
{{ end }}
{{ define "main" }}
{{ with .Params.image }}
<img class="coverimage" src="{{ . }}" />