diff --git a/assets/opengraph/background.png b/assets/opengraph/background.png new file mode 100644 index 0000000..99ab3a7 Binary files /dev/null and b/assets/opengraph/background.png differ diff --git a/assets/opengraph/background.png.txt b/assets/opengraph/background.png.txt new file mode 100644 index 0000000..e69de29 diff --git a/assets/opengraph/mulish-black.ttf b/assets/opengraph/mulish-black.ttf new file mode 100644 index 0000000..db680a0 Binary files /dev/null and b/assets/opengraph/mulish-black.ttf differ diff --git a/themes/nluug/layouts/partials/head.html b/themes/nluug/layouts/partials/head.html index 1b17134..5fced5c 100644 --- a/themes/nluug/layouts/partials/head.html +++ b/themes/nluug/layouts/partials/head.html @@ -5,12 +5,12 @@ {{ if eq .IsHome true }}{{ .Site.Title }}{{ else }}{{ .Title }} | {{ .Site.Title }}{{ end }} - {{ template "_internal/opengraph.html" . }} - {{ template "_internal/twitter_cards.html" . }} + {{ partial "opengraph/opengraph.html" . }} + {{ partial "opengraph/twitter_cards.html" . }} - - - + + + {{ partialCached "style.html" . }} diff --git a/themes/nluug/layouts/partials/opengraph/get-featured-image.html b/themes/nluug/layouts/partials/opengraph/get-featured-image.html new file mode 100644 index 0000000..d616b1f --- /dev/null +++ b/themes/nluug/layouts/partials/opengraph/get-featured-image.html @@ -0,0 +1,24 @@ +{{ $images := $.Resources.ByType "image" }} +{{ $featured := $images.GetMatch "*feature*" }} +{{ if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end }} +{{ if not $featured }} + {{ $featured = resources.Get "/opengraph/background.png" }} + {{ $size := 80 }} + {{ $title := $.LinkTitle }} + {{ if gt (len $title) 20 }} + {{ $size = 70 }} + {{ end }} + + {{ $text := $title }} + {{ $textOptions := dict + "color" "#1D3160" + "size" $size + "lineSpacing" 10 + "x" 65 "y" 80 + "font" (resources.Get "/opengraph/mulish-black.ttf") + }} + + {{ $featured = $featured | images.Filter (images.Text $text $textOptions) }} +{{ end }} + +{{ return $featured }} diff --git a/themes/nluug/layouts/partials/opengraph/opengraph.html b/themes/nluug/layouts/partials/opengraph/opengraph.html new file mode 100644 index 0000000..874a193 --- /dev/null +++ b/themes/nluug/layouts/partials/opengraph/opengraph.html @@ -0,0 +1,42 @@ + + + + + +{{- with $.Params.images -}} +{{- range first 6 . }}{{ end -}} +{{- else -}} +{{- $featured := partial "opengraph/get-featured-image.html" . }} +{{- with $featured -}} + +{{- else -}} +{{- with $.Site.Params.images }}{{ end -}} +{{- end -}} +{{- end -}} + +{{- if .IsPage }} +{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}} + +{{ with .PublishDate }}{{ end }} +{{ with .Lastmod }}{{ end }} +{{- end -}} + +{{- with .Params.audio }}{{ end }} +{{- with .Params.locale }}{{ end }} +{{- with .Site.Params.title }}{{ end }} +{{- with .Params.videos }}{{- range . }} + +{{ end }}{{ end }} + +{{- /* If it is part of a series, link to related articles */}} +{{- $permalink := .Permalink }} +{{- $siteSeries := .Site.Taxonomies.series }} +{{ with .Params.series }}{{- range $name := . }} + {{- $series := index $siteSeries ($name | urlize) }} + {{- range $page := first 6 $series.Pages }} + {{- if ne $page.Permalink $permalink }}{{ end }} + {{- end }} +{{ end }}{{ end }} + +{{- /* Facebook Page Admin ID for Domain Insights */}} +{{- with .Site.Social.facebook_admin }}{{ end }} diff --git a/themes/nluug/layouts/partials/opengraph/twitter_cards.html b/themes/nluug/layouts/partials/opengraph/twitter_cards.html new file mode 100644 index 0000000..9cd345c --- /dev/null +++ b/themes/nluug/layouts/partials/opengraph/twitter_cards.html @@ -0,0 +1,22 @@ +{{- with $.Params.images -}} + + +{{ else -}} +{{- $featured := partial "opengraph/get-featured-image.html" . }} +{{- with $featured -}} + + +{{- else -}} +{{- with $.Site.Params.images -}} + + +{{ else -}} + +{{- end -}} +{{- end -}} +{{- end }} + + +{{ with .Site.Social.twitter -}} + +{{ end -}}