main
html 103 lines 3.41 KB
Raw
1 <meta property="og:url" content="{{ .Permalink }}">
2
3 {{- with or site.Title site.Params.title | plainify }}
4 <meta property="og:site_name" content="{{ . }}">
5 {{- end }}
6
7 {{- with or .Title site.Title site.Params.title | plainify }}
8 <meta property="og:title" content="{{ . }}">
9 {{- end }}
10
11 {{- with or .Description .Summary site.Params.description | plainify | htmlUnescape }}
12 <meta property="og:description" content="{{ trim . "\n\r\t " }}">
13 {{- end }}
14
15 {{- with or .Params.locale site.Language.LanguageCode }}
16 <meta property="og:locale" content="{{ replace . `-` `_` }}">
17 {{- end }}
18
19 {{- if .IsPage }}
20 <meta property="og:type" content="article">
21 {{- with .Section }}
22 <meta property="article:section" content="{{ . }}">
23 {{- end }}
24 {{- $ISO8601 := "2006-01-02T15:04:05-07:00" }}
25 {{- with .PublishDate }}
26 <meta property="article:published_time" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
27 {{- end }}
28 {{- with .Lastmod }}
29 <meta property="article:modified_time" {{ .Format $ISO8601 | printf "content=%q" | safeHTMLAttr }}>
30 {{- end }}
31 {{- range .GetTerms "tags" | first 6 }}
32 <meta property="article:tag" content="{{ .Page.Title | plainify }}">
33 {{- end }}
34 {{- else }}
35 <meta property="og:type" content="website">
36 {{- end }}
37
38 {{- $ogImage := "" -}}
39 {{- $ogWidth := 0 -}}
40 {{- $ogHeight := 0 -}}
41 {{- if and .Params.og_image (not (hasPrefix .Params.og_image "http://")) (not (hasPrefix .Params.og_image "https://")) (not (hasPrefix .Params.og_image "//")) -}}
42 {{- with resources.Get .Params.og_image -}}
43 {{- $resized := .Fill "1200x630 jpg q85" -}}
44 {{- $ogImage = $resized.Permalink -}}
45 {{- $ogWidth = $resized.Width -}}
46 {{- $ogHeight = $resized.Height -}}
47 {{- end -}}
48 {{- end -}}
49 {{- $coverImage := .Params.cover.image -}}
50 {{- $coverImageIsLocal := and $coverImage (not (hasPrefix $coverImage "http://")) (not (hasPrefix $coverImage "https://")) (not (hasPrefix $coverImage "//")) -}}
51 {{- if $ogImage -}}
52 <meta property="og:image" content="{{ $ogImage }}">
53 <meta property="og:image:width" content="{{ $ogWidth }}">
54 <meta property="og:image:height" content="{{ $ogHeight }}">
55 {{- else if $coverImageIsLocal -}}
56 {{- if (ne .Params.cover.relative true) }}
57 <meta property="og:image" content="{{ $coverImage | absURL }}">
58 {{- else}}
59 <meta property="og:image" content="{{ (path.Join .RelPermalink $coverImage ) | absURL }}">
60 {{- end}}
61 {{- else }}
62 {{- with partial "_funcs/get-page-images" . }}
63 {{- range . | first 6 }}
64 <meta property="og:image" content="{{ .Permalink }}">
65 {{- end }}
66 {{- end }}
67 {{- end }}
68
69 {{- with .Params.audio }}
70 {{- range . | first 6 }}
71 <meta property="og:audio" content="{{ . | absURL }}">
72 {{- end }}
73 {{- end }}
74
75 {{- with .Params.videos }}
76 {{- range . | first 6 }}
77 <meta property="og:video" content="{{ . | absURL }}">
78 {{- end }}
79 {{- end }}
80
81 {{- range .GetTerms "series" }}
82 {{- range .Pages | first 7 }}
83 {{- if ne $ . }}
84 <meta property="og:see_also" content="{{ .Permalink }}">
85 {{- end }}
86 {{- end }}
87 {{- end }}
88
89 {{- with site.Params.social }}
90 {{- if reflect.IsMap . }}
91 {{- with .facebook_app_id }}
92 <meta property="fb:app_id" content="{{ . }}">
93 {{- else }}
94 {{- with .facebook_admin }}
95 <meta property="fb:admins" content="{{ . }}">
96 {{- end }}
97 {{- end }}
98 {{- end }}
99 {{- end }}
100
101 {{- with (.Param "social.fediverse_creator") }}
102 <meta name="fediverse:creator" content="{{ . }}">
103 {{- end }}