mirror of
https://github.com/jbowdre/runtimeterror.git
synced 2024-11-22 23:12:19 +00:00
generate og:image for homepage too
This commit is contained in:
parent
64dbcbb532
commit
74cfda7f25
1 changed files with 21 additions and 16 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
{{ $base := resources.Get "og_base.png" }}
|
||||||
|
{{ $font := resources.Get "/FiraMono-Regular.ttf" }}
|
||||||
<meta property="og:title" content="{{ .Title }}" />
|
<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: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:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
|
||||||
|
@ -5,29 +7,24 @@
|
||||||
<meta property="og:locale" content="{{ .Lang }}" />
|
<meta property="og:locale" content="{{ .Lang }}" />
|
||||||
{{- if .IsHome }}
|
{{- if .IsHome }}
|
||||||
<meta property="og:type" content="website">
|
<meta property="og:type" content="website">
|
||||||
<meta property="og:image" content="{{ .Site.Params.fallBackOgImage | absURL }}" />
|
{{ $img := $base.Filter (images.Text .Site.Params.Description (dict
|
||||||
{{- else }}
|
"color" "#d8d8d8"
|
||||||
<meta property="og:type" content="article">
|
"size" 64
|
||||||
|
"linespacing" 2
|
||||||
|
"x" 40
|
||||||
|
"y" 300
|
||||||
|
"font" $font
|
||||||
|
))}}
|
||||||
|
{{ $img = resources.Copy "og.png" $img }}
|
||||||
|
<meta property="og:image" content="{{$img.Permalink}}" />
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if .IsPage }}
|
{{- if .IsPage }}
|
||||||
|
<meta property="og:type" content="article">
|
||||||
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
|
||||||
<meta property="article:section" content="{{ .Section }}" />
|
<meta property="article:section" content="{{ .Section }}" />
|
||||||
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
{{ 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 .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
|
||||||
{{- end -}}
|
|
||||||
|
|
||||||
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
|
||||||
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
|
||||||
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
|
|
||||||
{{- with .Params.videos }}{{- range . }}
|
|
||||||
<meta property="og:video" content="{{ . | absURL }}" />
|
|
||||||
{{ end }}{{ end }}
|
|
||||||
|
|
||||||
{{- if .IsPage -}}
|
|
||||||
{{/* Generate opengraph image, based on https://aarol.dev/posts/hugo-og-image/ */}}
|
|
||||||
{{ $base := resources.Get "og_base.png" }}
|
|
||||||
{{ $font := resources.Get "/FiraMono-Regular.ttf"}}
|
|
||||||
{{ $img := $base.Filter (images.Text .Page.Title (dict
|
{{ $img := $base.Filter (images.Text .Page.Title (dict
|
||||||
"color" "#d8d8d8"
|
"color" "#d8d8d8"
|
||||||
"size" 64
|
"size" 64
|
||||||
|
@ -47,3 +44,11 @@
|
||||||
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with .Site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
|
||||||
<meta name="twitter:image" content="{{$img.Permalink}}" />
|
<meta name="twitter:image" content="{{$img.Permalink}}" />
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
|
||||||
|
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
|
||||||
|
{{- with .Site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
|
||||||
|
{{- with .Params.videos }}{{- range . }}
|
||||||
|
<meta property="og:video" content="{{ . | absURL }}" />
|
||||||
|
{{ end }}{{ end }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue