diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-05 18:10:34 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-06-05 18:10:42 +0200 |
| commit | 7d4a696a70969b82a55715221b85700a1e68d140 (patch) | |
| tree | f80a870391737b9afa1090f3f37975e95fbd1dd2 /layouts | |
| parent | 0c30ea398b6315e9b99afa4067a4897fad876d60 (diff) | |
| download | gohugo-theme-ed-7d4a696a70969b82a55715221b85700a1e68d140.tar.gz | |
Rework single post layouts
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/single.html | 25 | ||||
| -rw-r--r-- | layouts/_default/teaser.html | 4 | ||||
| -rw-r--r-- | layouts/dramas/single.html | 15 | ||||
| -rw-r--r-- | layouts/narratives/single.html | 15 | ||||
| -rw-r--r-- | layouts/page/single.html | 11 | ||||
| -rw-r--r-- | layouts/partials/page/single.html | 13 | ||||
| -rw-r--r-- | layouts/partials/post-class.html | 8 | ||||
| -rw-r--r-- | layouts/partials/post-meta.html | 9 | ||||
| -rw-r--r-- | layouts/poems/single.html | 15 |
9 files changed, 40 insertions, 75 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 56557e5..6be2a68 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -1,21 +1,28 @@ {{ define "main" }} -<article class="post" role="document"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> +{{- $postType := .Type | lower | singularize -}} +<article class="{{ partial "post-class.html" . }}" role="document"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> <header> <h1 class="text-title"> {{ .Params.caption | default .Title }} </h1> + <p class="byline"> + {{ if in (slice "drama" "narrative" "poem") $postType }} + {{ partial "post-meta/author.html" . }} + {{ else }} + {{ partial "post-meta/date.html" . }} + {{ end }} + </p> </header> - <p class="byline"> - {{ partial "post-meta/date.html" . }} - </p> - - <div class="post-body"> + <div class="{{ $postType }}-body"> {{ .Content }} </div> - <div class="post-tags-wrapper"> - {{ partial "post-tags.html" . }} - </div> + {{/* Post tags are not allowed for drama, narratives and poems */}} + {{ if not (in (slice "drama" "narrative" "poem") $postType) }} + <div class="tags-wrapper"> + {{ partial "post-tags.html" . }} + </div> + {{ end }} </article> {{ end }} diff --git a/layouts/_default/teaser.html b/layouts/_default/teaser.html index 441d779..82ea767 100644 --- a/layouts/_default/teaser.html +++ b/layouts/_default/teaser.html @@ -4,7 +4,9 @@ <h2 class="post-title"> <a href="{{ .Permalink }}" rel="bookmark">{{ .Title }}</a> </h2> - {{- partial "post-meta.html" . -}} + <p class="post-meta"> + {{- partial "post-meta/date.html" . -}} + </p> </header> <p class="post-content"> {{ .Summary }} diff --git a/layouts/dramas/single.html b/layouts/dramas/single.html deleted file mode 100644 index e47e531..0000000 --- a/layouts/dramas/single.html +++ /dev/null @@ -1,15 +0,0 @@ -{{ define "main" }} -<article class="drama" role="document"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> - <header> - <h1 class="text-title"> - {{ .Params.caption | default .Title }} - </h1> - </header> - - <p class="byline"> - {{ partial "post-meta/author.html" . }} - </p> - - {{ .Content }} -</article> -{{ end }} diff --git a/layouts/narratives/single.html b/layouts/narratives/single.html deleted file mode 100644 index c941bc2..0000000 --- a/layouts/narratives/single.html +++ /dev/null @@ -1,15 +0,0 @@ -{{ define "main" }} -<article class="narrative" role="document"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> - <header> - <h1 class="text-title"> - {{ .Params.caption | default .Title }} - </h1> - </header> - - <p class="byline"> - {{ partial "post-meta/author.html" . }} - </p> - - {{ .Content }} -</article> -{{ end }} diff --git a/layouts/page/single.html b/layouts/page/single.html deleted file mode 100644 index fef0cf5..0000000 --- a/layouts/page/single.html +++ /dev/null @@ -1,11 +0,0 @@ -{{ define "main" }} -<article class="page" role="document" id="page-{{ .File.TranslationBaseName | lower }}"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> - <header> - <h1 class="page-title"> - {{ .Params.caption | default .Title }} - </h1> - </header> - - {{ .Content }} -</article> -{{ end }} diff --git a/layouts/partials/page/single.html b/layouts/partials/page/single.html new file mode 100644 index 0000000..ca1180d --- /dev/null +++ b/layouts/partials/page/single.html @@ -0,0 +1,13 @@ +{{ define "main" }} +<article class="{{ partial "post-class.html" . }}" role="document" id="page-{{ .File.TranslationBaseName | lower }}"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> + <header> + <h1 class="page-title"> + {{ .Params.caption | default .Title }} + </h1> + </header> + + <div class="page-body"> + {{ .Content }} + </div> +</article> +{{ end }} diff --git a/layouts/partials/post-class.html b/layouts/partials/post-class.html new file mode 100644 index 0000000..1d32a8a --- /dev/null +++ b/layouts/partials/post-class.html @@ -0,0 +1,8 @@ +{{- $postClass := "page" -}} +{{- if .IsPage -}} + {{- $postClass = .Type | lower | singularize -}} + {{- if eq $postClass "poem" -}} + {{- $postClass = "poem poetry" -}} + {{- end -}} +{{- end -}} +{{- $postClass -}} diff --git a/layouts/partials/post-meta.html b/layouts/partials/post-meta.html deleted file mode 100644 index 19c3ce6..0000000 --- a/layouts/partials/post-meta.html +++ /dev/null @@ -1,9 +0,0 @@ -<div class="post-meta"> - {{- $root := . -}} - {{- with .Param "postMeta" -}} - {{- range $field := . -}} - {{- $p := printf "post-meta/%s.html" $field -}} - {{- partial $p $root -}} - {{- end -}} - {{- end -}} -</div> diff --git a/layouts/poems/single.html b/layouts/poems/single.html deleted file mode 100644 index 58038d1..0000000 --- a/layouts/poems/single.html +++ /dev/null @@ -1,15 +0,0 @@ -{{ define "main" }} -<article class="poem poetry" role="document"{{ with .Params.lang}} lang="{{ . }}"{{ end }}> - <header> - <h1 class="text-title"> - {{ .Params.caption | default .Title }} - </h1> - </header> - - <p class="byline"> - {{ partial "post-meta/author.html" . }} - </p> - - {{ .Content }} -</article> -{{ end }} |
