apps/posts/layout_templ.go 11.4 K raw
1
// Code generated by templ - DO NOT EDIT.
2
3
// templ: version: v0.3.1001
4
package main
5
6
//lint:file-ignore SA4006 This context is only used if a nested component is present.
7
8
import "github.com/a-h/templ"
9
import templruntime "github.com/a-h/templ/runtime"
10
11
func layout(site siteContext, title string, meta templ.Component, body templ.Component) templ.Component {
12
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
13
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
14
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
15
			return templ_7745c5c3_CtxErr
16
		}
17
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
18
		if !templ_7745c5c3_IsBuffer {
19
			defer func() {
20
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
21
				if templ_7745c5c3_Err == nil {
22
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
23
				}
24
			}()
25
		}
26
		ctx = templ.InitializeContext(ctx)
27
		templ_7745c5c3_Var1 := templ.GetChildren(ctx)
28
		if templ_7745c5c3_Var1 == nil {
29
			templ_7745c5c3_Var1 = templ.NopComponent
30
		}
31
		ctx = templ.ClearChildren(ctx)
32
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<!doctype html><html lang=\"en\"><head><meta charset=\"UTF-8\"><meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\"><title>")
33
		if templ_7745c5c3_Err != nil {
34
			return templ_7745c5c3_Err
35
		}
36
		var templ_7745c5c3_Var2 string
37
		templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(title)
38
		if templ_7745c5c3_Err != nil {
39
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 9, Col: 17}
40
		}
41
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
42
		if templ_7745c5c3_Err != nil {
43
			return templ_7745c5c3_Err
44
		}
45
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "</title>")
46
		if templ_7745c5c3_Err != nil {
47
			return templ_7745c5c3_Err
48
		}
49
		if site.FaviconURL != "" {
50
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"")
51
			if templ_7745c5c3_Err != nil {
52
				return templ_7745c5c3_Err
53
			}
54
			var templ_7745c5c3_Var3 templ.SafeURL
55
			templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinURLErrs(site.FaviconURL)
56
			if templ_7745c5c3_Err != nil {
57
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 11, Col: 71}
58
			}
59
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
60
			if templ_7745c5c3_Err != nil {
61
				return templ_7745c5c3_Err
62
			}
63
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\"><link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"")
64
			if templ_7745c5c3_Err != nil {
65
				return templ_7745c5c3_Err
66
			}
67
			var templ_7745c5c3_Var4 templ.SafeURL
68
			templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinURLErrs(site.FaviconURL)
69
			if templ_7745c5c3_Err != nil {
70
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 12, Col: 74}
71
			}
72
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
73
			if templ_7745c5c3_Err != nil {
74
				return templ_7745c5c3_Err
75
			}
76
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\"><link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"")
77
			if templ_7745c5c3_Err != nil {
78
				return templ_7745c5c3_Err
79
			}
80
			var templ_7745c5c3_Var5 templ.SafeURL
81
			templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinURLErrs(site.FaviconURL)
82
			if templ_7745c5c3_Err != nil {
83
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 13, Col: 74}
84
			}
85
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
86
			if templ_7745c5c3_Err != nil {
87
				return templ_7745c5c3_Err
88
			}
89
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "\">")
90
			if templ_7745c5c3_Err != nil {
91
				return templ_7745c5c3_Err
92
			}
93
		} else {
94
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<link rel=\"apple-touch-icon\" sizes=\"180x180\" href=\"/static/apple-touch-icon.png\"><link rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/static/favicon-32x32.png\"><link rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/static/favicon-16x16.png\"><link rel=\"manifest\" href=\"/static/site.webmanifest\">")
95
			if templ_7745c5c3_Err != nil {
96
				return templ_7745c5c3_Err
97
			}
98
		}
99
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<meta name=\"theme-color\" content=\"#121113\">")
100
		if templ_7745c5c3_Err != nil {
101
			return templ_7745c5c3_Err
102
		}
103
		templ_7745c5c3_Err = meta.Render(ctx, templ_7745c5c3_Buffer)
104
		if templ_7745c5c3_Err != nil {
105
			return templ_7745c5c3_Err
106
		}
107
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<link rel=\"stylesheet\" href=\"/assets/darkmatter.css\"><link rel=\"stylesheet\" href=\"/static/styles.css\"><link rel=\"stylesheet\" href=\"/custom-styles.css\"></head><body>")
108
		if templ_7745c5c3_Err != nil {
109
			return templ_7745c5c3_Err
110
		}
111
		if site.HeaderHTML != "" {
112
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "<div class=\"custom-header\">")
113
			if templ_7745c5c3_Err != nil {
114
				return templ_7745c5c3_Err
115
			}
116
			templ_7745c5c3_Err = templ.Raw(string(site.HeaderHTML)).Render(ctx, templ_7745c5c3_Buffer)
117
			if templ_7745c5c3_Err != nil {
118
				return templ_7745c5c3_Err
119
			}
120
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</div>")
121
			if templ_7745c5c3_Err != nil {
122
				return templ_7745c5c3_Err
123
			}
124
		}
125
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<header class=\"header\"><a href=\"/\" class=\"logo\">")
126
		if templ_7745c5c3_Err != nil {
127
			return templ_7745c5c3_Err
128
		}
129
		var templ_7745c5c3_Var6 string
130
		templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(site.BlogTitle)
131
		if templ_7745c5c3_Err != nil {
132
			return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 33, Col: 45}
133
		}
134
		_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
135
		if templ_7745c5c3_Err != nil {
136
			return templ_7745c5c3_Err
137
		}
138
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</a><nav class=\"links\">")
139
		if templ_7745c5c3_Err != nil {
140
			return templ_7745c5c3_Err
141
		}
142
		for _, l := range site.NavLinks {
143
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<a href=\"")
144
			if templ_7745c5c3_Err != nil {
145
				return templ_7745c5c3_Err
146
			}
147
			var templ_7745c5c3_Var7 templ.SafeURL
148
			templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinURLErrs(templ.URL(l.URL))
149
			if templ_7745c5c3_Err != nil {
150
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 36, Col: 32}
151
			}
152
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
153
			if templ_7745c5c3_Err != nil {
154
				return templ_7745c5c3_Err
155
			}
156
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "\">")
157
			if templ_7745c5c3_Err != nil {
158
				return templ_7745c5c3_Err
159
			}
160
			var templ_7745c5c3_Var8 string
161
			templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(l.Label)
162
			if templ_7745c5c3_Err != nil {
163
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 36, Col: 44}
164
			}
165
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
166
			if templ_7745c5c3_Err != nil {
167
				return templ_7745c5c3_Err
168
			}
169
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</a>")
170
			if templ_7745c5c3_Err != nil {
171
				return templ_7745c5c3_Err
172
			}
173
		}
174
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</nav></header><main>")
175
		if templ_7745c5c3_Err != nil {
176
			return templ_7745c5c3_Err
177
		}
178
		templ_7745c5c3_Err = body.Render(ctx, templ_7745c5c3_Buffer)
179
		if templ_7745c5c3_Err != nil {
180
			return templ_7745c5c3_Err
181
		}
182
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</main><footer class=\"footer\">")
183
		if templ_7745c5c3_Err != nil {
184
			return templ_7745c5c3_Err
185
		}
186
		templ_7745c5c3_Err = templ.Raw(string(site.FooterHTML)).Render(ctx, templ_7745c5c3_Buffer)
187
		if templ_7745c5c3_Err != nil {
188
			return templ_7745c5c3_Err
189
		}
190
		templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "</footer><script>\n\t\t\t\tdocument.querySelectorAll('.post-date').forEach(el => {\n\t\t\t\t\tconst d = new Date(el.textContent.trim());\n\t\t\t\t\tif (!isNaN(d)) {\n\t\t\t\t\t\tconst day = String(d.getDate()).padStart(2, '0');\n\t\t\t\t\t\tconst mon = d.toLocaleString('en-US', { month: 'short' });\n\t\t\t\t\t\tel.textContent = `${day} ${mon}, ${d.getFullYear()}`;\n\t\t\t\t\t}\n\t\t\t\t});\n\t\t\t</script></body></html>")
191
		if templ_7745c5c3_Err != nil {
192
			return templ_7745c5c3_Err
193
		}
194
		return nil
195
	})
196
}
197
198
func ogImage(site siteContext) templ.Component {
199
	return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
200
		templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
201
		if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
202
			return templ_7745c5c3_CtxErr
203
		}
204
		templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
205
		if !templ_7745c5c3_IsBuffer {
206
			defer func() {
207
				templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
208
				if templ_7745c5c3_Err == nil {
209
					templ_7745c5c3_Err = templ_7745c5c3_BufErr
210
				}
211
			}()
212
		}
213
		ctx = templ.InitializeContext(ctx)
214
		templ_7745c5c3_Var9 := templ.GetChildren(ctx)
215
		if templ_7745c5c3_Var9 == nil {
216
			templ_7745c5c3_Var9 = templ.NopComponent
217
		}
218
		ctx = templ.ClearChildren(ctx)
219
		if site.OGImageURL != "" {
220
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<meta property=\"og:image\" content=\"")
221
			if templ_7745c5c3_Err != nil {
222
				return templ_7745c5c3_Err
223
			}
224
			var templ_7745c5c3_Var10 string
225
			templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(site.OGImageURL)
226
			if templ_7745c5c3_Err != nil {
227
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 62, Col: 53}
228
			}
229
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
230
			if templ_7745c5c3_Err != nil {
231
				return templ_7745c5c3_Err
232
			}
233
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\">")
234
			if templ_7745c5c3_Err != nil {
235
				return templ_7745c5c3_Err
236
			}
237
		} else {
238
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<meta property=\"og:image\" content=\"")
239
			if templ_7745c5c3_Err != nil {
240
				return templ_7745c5c3_Err
241
			}
242
			var templ_7745c5c3_Var11 string
243
			templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(site.SiteURL + "/static/og.png")
244
			if templ_7745c5c3_Err != nil {
245
				return templ.Error{Err: templ_7745c5c3_Err, FileName: `layout.templ`, Line: 64, Col: 69}
246
			}
247
			_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
248
			if templ_7745c5c3_Err != nil {
249
				return templ_7745c5c3_Err
250
			}
251
			templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "\">")
252
			if templ_7745c5c3_Err != nil {
253
				return templ_7745c5c3_Err
254
			}
255
		}
256
		return nil
257
	})
258
}
259
260
var _ = templruntime.GeneratedTemplate