fix social card thumbnail for HLTB entries

This commit is contained in:
Wouter Groeneveld 2023-01-10 14:32:16 +01:00
parent 0f97c6c78d
commit 1fd758e97e
1 changed files with 24 additions and 29 deletions

View File

@ -2,9 +2,9 @@
{{ $base := .Site.BaseURL }} {{ $base := .Site.BaseURL }}
<meta charset="utf-8"> <meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta http-equiv="X-UA-Compatible" content="IE=edge">
{{ if .Title }} {{- if .Title }}
<title>{{ .Title }} | {{ .Site.Title }}</title> <title>{{ .Title }} | {{ .Site.Title }}</title>
{{ else }} {{- else }}
<title>{{ .Site.Title }}</title> <title>{{ .Site.Title }}</title>
{{ end }} {{ end }}
<meta content="{{ .Title }} | {{ .Site.Title }}" property="og:title"> <meta content="{{ .Title }} | {{ .Site.Title }}" property="og:title">
@ -17,61 +17,56 @@
<link rel="author" href="{{ $base }}humans.txt" type="text/plain" /> <link rel="author" href="{{ $base }}humans.txt" type="text/plain" />
<link rel="webmention" href="https://jam.brainbaking.com/webmention" /> <link rel="webmention" href="https://jam.brainbaking.com/webmention" />
<link rel="pingback" href="https://jam.brainbaking.com/pingback" /> <link rel="pingback" href="https://jam.brainbaking.com/pingback" />
{{- if .Description }}
{{ if .Description }}
<meta name="description" content="{{ .Title }}. {{ .Description | safeHTML }} Via {{ .Site.Title }}"> <meta name="description" content="{{ .Title }}. {{ .Description | safeHTML }} Via {{ .Site.Title }}">
<meta content="{{ .Title }}. {{ .Description | safeHTML }} Via {{ .Site.Title }}" property="og:description"> <meta content="{{ .Title }}. {{ .Description | safeHTML }} Via {{ .Site.Title }}" property="og:description">
{{ else }} {{- else }}
<meta name="description" content="{{ .Title }}. {{ .Summary | safeHTML }}"> <meta name="description" content="{{ .Title }}. {{ .Summary | safeHTML }}">
<meta content="{{ .Title }}. {{ .Summary | safeHTML }} Via {{ .Site.Title }}" property="og:description"> <meta content="{{ .Title }}. {{ .Summary | safeHTML }} Via {{ .Site.Title }}" property="og:description">
{{ end }} {{ end }}
{{- if .Keywords }}
{{ if .Keywords }}
<meta content="{{ delimit .Keywords ", " }}, {{ .Title }}" name="keywords"> <meta content="{{ delimit .Keywords ", " }}, {{ .Title }}" name="keywords">
{{ else if .Params.tags }} {{- else if .Params.tags }}
<meta content="{{ delimit .Params.tags ", " }}, {{ .Title }}" name="keywords"> <meta content="{{ delimit .Params.tags ", " }}, {{ .Title }}" name="keywords">
{{ end }} {{ end }}
<!-- opengraph meta --> <!-- opengraph meta -->
<!-- see https://github.com/nozzle/hugo-snippets/blob/master/layouts/partials/head/seo/open_graph.html --> <!-- see https://github.com/nozzle/hugo-snippets/blob/master/layouts/partials/head/seo/open_graph.html -->
<meta property="og:url" content="{{ $perm }}" /> <meta property="og:url" content="{{ $perm }}" />
<meta property="og:type" content="{{ if .Params.type }}{{ .Params.type }}{{ else }}website{{ end }}" /> <meta property="og:type" content="{{ if .Params.type }}{{ .Params.type }}{{ else }}website{{ end }}" />
{{ $thumb := "img/favicon.png" | absURL }} {{- $thumb := "img/favicon.png" | absURL }}
{{ if .Params.image }} {{- if .Params.image }}
{{ $thumb = .Params.image | absURL }} {{- $thumb = .Params.image | absURL }}
{{ else if .Params.howlongtobeat_id }} {{- else if .Params.howlongtobeat_id }}
{{ $thumb = printf "%s%d%s" "img/hltb/" .Params.howlongtobeat_id ".jpg" | absURL }} {{- $thumb = printf "%s%s" $perm "cover.jpg" | absURL }}
{{ else }} {{- else }}
{{ $match := findRE `!\[(.*)\]\((.+).(jpg|png|gif)` .RawContent 1 }} {{- $match := findRE `!\[(.*)\]\((.+).(jpg|png|gif)` .RawContent 1 }}
{{ range $match }} {{- range $match }}
{{ $relthumb := replaceRE `!\[(.*)\]\(` "" . }} {{- $relthumb := replaceRE `!\[(.*)\]\(` "" . }}
{{ if hasPrefix $relthumb "/" }} {{- if hasPrefix $relthumb "/" }}
{{ $thumb = printf "%s%s" $base $relthumb }} {{- $thumb = printf "%s%s" $base $relthumb }}
{{ else }} {{- else }}
{{ $thumb = printf "%s%s" $perm $relthumb }} {{- $thumb = printf "%s%s" $perm $relthumb }}
{{ end }} {{ end }}
{{ end }} {{ end }}
{{ end }} {{ end }}
<meta property="og:image" content="{{ $thumb }}" /> <meta property="og:image" content="{{ $thumb }}" />
<!-- zie sidebar.html, zelfde logica gebruikt --> <!-- zie sidebar.html, zelfde logica gebruikt -->
{{ $related := first 3 (where (where (where .Site.Pages.ByDate.Reverse ".Type" "==" "articles") ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" $perm) }} {{- $related := first 3 (where (where (where .Site.Pages.ByDate.Reverse ".Type" "==" "articles") ".Params.tags" "intersect" .Params.tags) "Permalink" "!=" $perm) }}
{{ if $related }} {{- if $related }}
{{ range $related }} {{- range $related }}
<meta property="og:see_also" content="{{ $perm }}" /> <meta property="og:see_also" content="{{ $perm }}" />
{{ end }} {{ end }}
{{ end }} {{ end }}
<meta property="article:published_time" content="{{ .PublishDate }}" /> <meta property="article:published_time" content="{{ .PublishDate }}" />
<meta property="article:modified_time" content="{{ .Date }}" /> <meta property="article:modified_time" content="{{ .Date }}" />
<meta property="article:section" content="{{ .Section }}" /> <meta property="article:section" content="{{ .Section }}" />
{{ with .Params.tags }}{{ range first 6 . }} {{- with .Params.tags }}{{ range first 6 . }}
<meta property="article:tag" content="{{ . }}" /> <meta property="article:tag" content="{{ . }}" />
{{ end }}{{ end }} {{ end }}{{ end }}
<!-- end og --> <!-- end og -->
<!-- structured data --> <!-- structured data -->
{{ $ISO8601 := "2006-01-02T15:04:05-07:00" }} {{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
<script type="application/ld+json"> <script type="application/ld+json">
{ {
"@context" : "http://schema.org", "@context" : "http://schema.org",