mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-11-22 15:02:18 +00:00
opengraph efficiency++
This commit is contained in:
parent
02626117fd
commit
55c8934ebc
1 changed files with 10 additions and 30 deletions
|
@ -1,21 +1,13 @@
|
|||
{{ $base := resources.Get "og_base.png" }}
|
||||
{{ $img := resources.Get "og_base.png" }}
|
||||
{{ $font := resources.Get "/FiraMono-Regular.ttf" }}
|
||||
{{ $text := "" }}
|
||||
<meta property="og:title" content="{{ .Title }}" />
|
||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
|
||||
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||
<meta property="og:url" content="{{ .Permalink }}" />
|
||||
<meta property="og:locale" content="{{ .Lang }}" />
|
||||
{{- if .IsHome }}
|
||||
{{ $img := $base.Filter (images.Text .Site.Params.Description (dict
|
||||
"color" "#d8d8d8"
|
||||
"size" 64
|
||||
"linespacing" 2
|
||||
"x" 40
|
||||
"y" 300
|
||||
"font" $font
|
||||
))}}
|
||||
{{ $img = resources.Copy "og.png" $img }}
|
||||
{{ .Scratch.Set "og_image" $img }}
|
||||
{{ $text = .Site.Params.Description }}
|
||||
{{- end }}
|
||||
|
||||
{{- if .IsPage }}
|
||||
|
@ -23,11 +15,15 @@
|
|||
<meta property="article:section" content="{{ .Section }}" />
|
||||
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||
{{ with .Params.thumbnail }}
|
||||
{{ $text = .Page.Title }}
|
||||
{{ end }}
|
||||
|
||||
{{- with .Params.thumbnail }}
|
||||
{{ $thumbnail := $.Resources.Get . }}
|
||||
{{ with $thumbnail }}
|
||||
{{ $img := $base.Filter (images.Overlay (.Process "fit 300x250") 875 38 )}}
|
||||
{{ $img = $img.Filter (images.Text $.Page.Title (dict
|
||||
{{ $img = $img.Filter (images.Overlay (.Process "fit 300x250") 875 38 )}}
|
||||
{{ end }}{{ end }}
|
||||
{{ $img = $img.Filter (images.Text $text (dict
|
||||
"color" "#d8d8d8"
|
||||
"size" 64
|
||||
"linespacing" 2
|
||||
|
@ -36,22 +32,6 @@
|
|||
"font" $font
|
||||
))}}
|
||||
{{ $img = resources.Copy (path.Join $.Page.RelPermalink "og.png") $img }}
|
||||
{{ $.Scratch.Set "og_image" $img }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ $img := $base.Filter (images.Text .Page.Title (dict
|
||||
"color" "#d8d8d8"
|
||||
"size" 64
|
||||
"linespacing" 2
|
||||
"x" 40
|
||||
"y" 300
|
||||
"font" $font
|
||||
))}}
|
||||
{{ $img = resources.Copy (path.Join $.Page.RelPermalink "og.png") $img }}
|
||||
{{ .Scratch.Set "og_image" $img }}
|
||||
{{ end }}
|
||||
{{- end -}}
|
||||
{{ $img := .Scratch.Get "og_image" }}
|
||||
|
||||
<meta property="og:image" content="{{$img.Permalink}}">
|
||||
<meta property="og:image:width" content="{{$img.Width}}" />
|
||||
|
|
Loading…
Reference in a new issue