Skip to content

Commit 96efbfe

Browse files
committed
refactor: simplify single post layout and enhance formatting
- Standardized indentation and cleaned up HTML structure. - Improved cover image logic and captions for semantic accuracy. - Refined date display with accessible formatting and concise updates logic.
1 parent f2ab95b commit 96efbfe

1 file changed

Lines changed: 26 additions & 36 deletions

File tree

themes/custom/layouts/posts/single.html

Lines changed: 26 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,36 @@
11
{{ define "main" }}
22
<article class="space-y-4" aria-labelledby="post-title">
33
{{- with .Params.cover.image -}}
4-
{{- if not $.Params.cover.alt -}}
5-
{{- errorf "cover.alt is required when cover.image is set for %q" $.File.Path -}}
6-
{{- end -}}
7-
{{- $imageAlt := $.Params.cover.alt -}}
8-
{{- $coverTitle := $.Params.cover.title -}}
9-
{{- $coverCaption := $.Params.cover.caption -}}
10-
<figure class="relative overflow-hidden rounded-2xl border border-slate-200 shadow-sm dark:border-slate-800">
4+
{{- if not $.Params.cover.alt -}}
5+
{{- errorf "cover.alt is required when cover.image is set for %q" $.File.Path -}}
6+
{{- end -}}
7+
{{- $imageAlt := $.Params.cover.alt -}}
8+
{{- $coverTitle := $.Params.cover.title -}}
9+
{{- $coverCaption := $.Params.cover.caption -}}
10+
<figure class="relative overflow-hidden rounded-2xl border border-slate-200 shadow-sm dark:border-slate-800">
1111
{{ partial "image.html" (dict
12-
"page" $
13-
"src" .
14-
"alt" $imageAlt
15-
"class" "w-full object-cover"
16-
"sizes" "(max-width: 768px) 100vw, 768px"
17-
"loading" "eager"
18-
"decoding" "async"
19-
"fetchpriority" "high"
20-
) }}
21-
22-
{{- with $coverCaption -}}
23-
<figcaption
24-
class="absolute inset-x-0 bottom-0 px-4 py-2 text-center text-xs text-slate-100 bg-black/50 backdrop-blur-sm">
25-
{{ . }}
26-
</figcaption>
27-
{{- end -}}
28-
</figure>
29-
{{- end -}}
12+
"page" $
13+
"src" .
14+
"alt" $imageAlt
15+
"class" "w-full object-cover"
16+
"sizes" "(max-width: 768px) 100vw, 768px"
17+
"loading" "eager"
18+
"decoding" "async"
19+
"fetchpriority" "high")
20+
}}
21+
{{- with $coverCaption -}}
22+
<figcaption class="absolute inset-x-0 bottom-0 px-4 py-2 text-center text-xs text-slate-100 bg-black/50 backdrop-blur-sm">
23+
{{ . }}
24+
</figcaption>
25+
{{- end -}}
26+
</figure>{{- end -}}
3027

3128
<header class="space-y-2">
32-
<h1 id="post-title" class="text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ .Title }}</h1>
29+
<h1 class="text-2xl font-semibold text-slate-900 dark:text-slate-100">{{ .Title }}</h1>
3330
{{- with .Date -}}
34-
<div class="text-sm text-slate-500 dark:text-slate-400">
35-
Gepubliceerd op
36-
<time datetime="{{ .Format " 2006-01-02
37-
" }}">{{ partial "date.html" (dict "date" . "format" ":date_long") }}</time>
38-
{{- if and $.Lastmod (gt $.Lastmod $.Date) -}}
39-
<span> · Bijgewerkt op</span>
40-
<time datetime="{{ $.Lastmod.Format " 2006-01-02
41-
" }}">{{ partial "date.html" (dict "date" $.Lastmod "format" ":date_long") }}</time>
42-
{{- end -}}
43-
</div>
31+
<p class="text-sm text-slate-500 dark:text-slate-400">
32+
Gepubliceerd op {{ partial "date.html" (dict "date" . "format" ":date_long") }}{{ if and $.Lastmod (gt (sub $.Lastmod.Unix $.Date.Unix) 86400) }} · bijgewerkt {{ partial "date.html" (dict "date" $.Lastmod "format" ":date_long") }}{{ end }}
33+
</p>
4434
{{- end -}}
4535
</header>
4636

0 commit comments

Comments
 (0)