2
2
3
3
{{/* 1. Try to find the auto-generated OG image: [slug]-og.jpg */}}
4
4
{{ if .File }}
5
- {{ $pageSlug := path.Base .File.Dir }}
6
- {{ $generatedOgImageName := printf "%s-og.jpg" $pageSlug }}
7
- {{ $ogImageResource = .Resources.GetMatch $generatedOgImageName }}
5
+ {{ $pageSlug := path.Base .File.Dir }}
6
+ {{ $generatedOgImageName := printf "%s-og.jpg" $pageSlug }}
7
+ {{ $ogImageResource = .Resources.GetMatch $generatedOgImageName }}
8
8
{{ end }}
9
9
10
10
{{/* 2. If not found, fall back to the `image` param in front matter */}}
11
11
{{ if not $ogImageResource }}
12
- {{ with .Params.image }}
13
- {{ $fmImage := . }}
14
- {{ $ogImageResource = $.Page.Resources.GetMatch $fmImage }}
15
- {{ if not $ogImageResource }}
16
- {{ $ogImageResource = resources.Get $fmImage }}
17
- {{ end }}
18
- {{ end }}
12
+ {{ with .Params.image }}
13
+ {{ $fmImage := . }}
14
+ {{ $ogImageResource = $.Page.Resources.GetMatch $fmImage }}
15
+ {{ if not $ogImageResource }}
16
+ {{ $ogImageResource = resources.Get $fmImage }}
17
+ {{ end }}
18
+ {{ end }}
19
19
{{ end }}
20
20
21
21
{{/* 3. If still not found, use a site-wide default */}}
22
22
{{ if not $ogImageResource }}
23
- {{ with site.Params.metadata.image }}
24
- {{ $ogImageResource = resources.Get . }}
25
- {{ end }}
23
+ {{ with site.Params.metadata.image }}
24
+ {{ $ogImageResource = resources.Get . }}
25
+ {{ end }}
26
26
{{ end }}
27
27
28
28
29
29
{{ if $ogImageResource }}
30
- {{ $resizedOg := $ogImageResource.Fill "600x315 Lanczos q85" }}
31
- {{ $ogImageDisplay := $resizedOg.RelPermalink }}
30
+ {{ $resizedOg := $ogImageResource.Resize "600x Lanczos q85" }}
31
+ {{ $ogImageDisplay := $resizedOg.RelPermalink }}
32
32
33
- < div class ="og-preview-wrapper ">
34
- < div class ="og-preview-container ">
35
- < div class ="og-preview-image " style ="background-image: url('{{ $ogImageDisplay }}') ">
36
- < div class ="image-dark-overlay "> </ div >
37
- < div class ="social-share-overlay ">
38
- < div class ="social-icons-container ">
39
- < a href ="https://twitter.com/intent/tweet/?text={{ .Title | urlquery }}&url={{ .Permalink | absURL }} " target ="_blank " rel ="noopener " class ="social-icon " title ="Share on X/Twitter ">
40
- {{ partial "icon.html" (dict "style" "brands" "name" "x-twitter") }}
41
- </ a >
42
- < a href ="https://www.facebook.com/sharer/sharer.php?u={{ .Permalink | absURL }} " target ="_blank " rel ="noopener " class ="social-icon " title ="Share on Facebook ">
43
- {{ partial "icon.html" (dict "style" "brands" "name" "facebook") }}
44
- </ a >
45
- < a href ="https://www.linkedin.com/shareArticle?mini=true&url={{ .Permalink | absURL }}&title={{ .Title | urlquery }} " target ="_blank " rel ="noopener " class ="social-icon " title ="Share on LinkedIn ">
46
- {{ partial "icon.html" (dict "style" "brands" "name" "linkedin") }}
47
- </ a >
48
- </ div >
49
- </ div >
50
- </ div >
51
- < div class ="sharing-runner ">
52
- < span > Share this post</ span >
53
- < div class ="runner-icons ">
33
+ < div class ="og-preview-wrapper ">
34
+ < div class ="og-preview-container ">
35
+ < img src ="{{ $ogImageDisplay }} " alt ="Social share preview for {{ .Title }} " class ="og-preview-image-tag " />
36
+
37
+ < div class ="image-dark-overlay "> </ div >
38
+ < div class ="social-share-overlay ">
39
+ < div class ="social-icons-container ">
40
+ < a href ="https://twitter.com/intent/tweet/?text={{ .Title | urlquery }}&url={{ .Permalink | absURL }} " target ="_blank " rel ="noopener " class ="social-icon " title ="Share on X/Twitter ">
54
41
{{ partial "icon.html" (dict "style" "brands" "name" "x-twitter") }}
42
+ </ a >
43
+ < a href ="https://www.facebook.com/sharer/sharer.php?u={{ .Permalink | absURL }} " target ="_blank " rel ="noopener " class ="social-icon " title ="Share on Facebook ">
55
44
{{ partial "icon.html" (dict "style" "brands" "name" "facebook") }}
45
+ </ a >
46
+ < a href ="https://www.linkedin.com/shareArticle?mini=true&url={{ .Permalink | absURL }}&title={{ .Title | urlquery }} " target ="_blank " rel ="noopener " class ="social-icon " title ="Share on LinkedIn ">
56
47
{{ partial "icon.html" (dict "style" "brands" "name" "linkedin") }}
57
- </ div >
48
+ </ a >
49
+ </ div >
50
+ </ div >
51
+ < div class ="sharing-runner ">
52
+ < span > Share this post</ span >
53
+ < div class ="runner-icons ">
54
+ {{ partial "icon.html" (dict "style" "brands" "name" "x-twitter") }}
55
+ {{ partial "icon.html" (dict "style" "brands" "name" "facebook") }}
56
+ {{ partial "icon.html" (dict "style" "brands" "name" "linkedin") }}
58
57
</ div >
59
58
</ div >
60
59
</ div >
61
- {{ end }}
60
+ </ div >
61
+ {{ end }}
0 commit comments