Skip to content

Commit fa2eefb

Browse files
author
Florian Bramer
committed
Adjusted Theme
1 parent cf421fb commit fa2eefb

File tree

3 files changed

+108
-0
lines changed

3 files changed

+108
-0
lines changed

layouts/partials/post_meta.html

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{{- $scratch := newScratch }}
2+
3+
{{- if not .Date.IsZero -}}
4+
{{- $scratch.Add "meta" (slice (printf "<span title='%s'>%s</span>" (.Date) (.Date | time.Format (default ":date_long" site.Params.DateFormat)))) }}
5+
{{- end }}
6+
7+
{{- if (.Param "ShowReadingTime") -}}
8+
{{- $scratch.Add "meta" (slice (printf "<span>%s</span>" (i18n "read_time" .ReadingTime | default (printf "%d min" .ReadingTime)))) }}
9+
{{- end }}
10+
11+
{{- if (.Param "ShowWordCount") -}}
12+
{{- $scratch.Add "meta" (slice (printf "<span>%s</span>" (i18n "words" .WordCount | default (printf "%d words" .WordCount)))) }}
13+
{{- end }}
14+
15+
{{- if not (.Param "hideAuthor") -}}
16+
{{- with (partial "author.html" .) }}
17+
{{- $scratch.Add "meta" (slice (printf "<span>%s</span>" .)) }}
18+
{{- end }}
19+
{{- end }}
20+
21+
{{- with ($scratch.Get "meta") }}
22+
{{- delimit . "&nbsp;·&nbsp;" | safeHTML -}}
23+
{{- end -}}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<meta property="og:title" content="{{ .Title }}" />
2+
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end }}" />
3+
<meta property="og:type" content="{{ if .IsPage }}article{{ else }}website{{ end }}" />
4+
<meta property="og:url" content="{{ .Permalink }}" />
5+
{{- if .Params.cover.image -}}
6+
{{- if (ne .Params.cover.relative true) }}
7+
<meta property="og:image" content="{{ .Params.cover.image | absURL }}" />
8+
{{- else}}
9+
<meta property="og:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
10+
{{- end}}
11+
{{- else }}
12+
13+
{{- with $.Params.images -}}
14+
{{- range first 6 . }}<meta property="og:image" content="{{ . | absURL }}" />{{ end -}}
15+
{{- else -}}
16+
{{- $images := $.Resources.ByType "image" -}}
17+
{{- $featured := $images.GetMatch "*feature*" -}}
18+
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
19+
{{- with $featured -}}
20+
<meta property="og:image" content="{{ $featured.Permalink }}"/>
21+
{{- else -}}
22+
{{- with site.Params.images }}<meta property="og:image" content="{{ index . 0 | absURL }}"/>{{ end -}}
23+
{{- end -}}
24+
{{- end -}}
25+
{{- end }}
26+
27+
{{- if .IsPage }}
28+
{{- $iso8601 := "2006-01-02T15:04:05-07:00" -}}
29+
<meta property="article:section" content="{{ .Section }}" />
30+
{{ with .PublishDate }}<meta property="article:published_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
31+
{{ with .Lastmod }}<meta property="article:modified_time" {{ .Format $iso8601 | printf "content=%q" | safeHTMLAttr }} />{{ end }}
32+
{{- end -}}
33+
34+
{{- with .Params.audio }}<meta property="og:audio" content="{{ . }}" />{{ end }}
35+
{{- with .Params.locale }}<meta property="og:locale" content="{{ . }}" />{{ end }}
36+
{{- with site.Params.title }}<meta property="og:site_name" content="{{ . }}" />{{ end }}
37+
{{- with .Params.videos }}{{- range . }}
38+
<meta property="og:video" content="{{ . | absURL }}" />
39+
{{ end }}{{ end }}
40+
41+
{{- /* If it is part of a series, link to related articles */}}
42+
{{- $permalink := .Permalink }}
43+
{{- $siteSeries := site.Taxonomies.series }}
44+
{{ with .Params.series }}{{- range $name := . }}
45+
{{- $series := index $siteSeries ($name | urlize) }}
46+
{{- range $page := first 6 $series.Pages }}
47+
{{- if ne $page.Permalink $permalink }}<meta property="og:see_also" content="{{ $page.Permalink }}" />{{ end }}
48+
{{- end }}
49+
{{ end }}{{ end }}
50+
51+
{{- /* Facebook Page Admin ID for Domain Insights */}}
52+
{{- with site.Params.social.facebook_admin }}<meta property="fb:admins" content="{{ . }}" />{{ end }}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{{- if .Params.cover.image -}}
2+
<meta name="twitter:card" content="summary_large_image" />
3+
{{- if (ne $.Params.cover.relative true) }}
4+
<meta name="twitter:image" content="{{ .Params.cover.image | absURL }}" />
5+
{{- else }}
6+
<meta name="twitter:image" content="{{ (path.Join .RelPermalink .Params.cover.image ) | absURL }}" />
7+
{{- end}}
8+
{{- else }}
9+
{{- with $.Params.images -}}
10+
<meta name="twitter:card" content="summary_large_image"/>
11+
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
12+
{{ else -}}
13+
{{- $images := $.Resources.ByType "image" -}}
14+
{{- $featured := $images.GetMatch "*feature*" -}}
15+
{{- if not $featured }}{{ $featured = $images.GetMatch "{*cover*,*thumbnail*}" }}{{ end -}}
16+
{{- with $featured -}}
17+
<meta name="twitter:card" content="summary_large_image"/>
18+
<meta name="twitter:image" content="{{ $featured.Permalink }}"/>
19+
{{- else -}}
20+
{{- with site.Params.images -}}
21+
<meta name="twitter:card" content="summary_large_image"/>
22+
<meta name="twitter:image" content="{{ index . 0 | absURL }}"/>
23+
{{ else -}}
24+
<meta name="twitter:card" content="summary"/>
25+
{{- end -}}
26+
{{- end -}}
27+
{{- end }}
28+
{{- end }}
29+
<meta name="twitter:title" content="{{ .Title }}"/>
30+
<meta name="twitter:description" content="{{ with .Description }}{{ . }}{{ else }}{{if .IsPage}}{{ .Summary }}{{ else }}{{ with site.Params.description }}{{ . }}{{ end }}{{ end }}{{ end -}}"/>
31+
{{ with site.Params.social.twitter -}}
32+
<meta name="twitter:site" content="@{{ . }}"/>
33+
{{ end -}}

0 commit comments

Comments
 (0)