diff options
| author | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-31 09:35:31 +0200 |
|---|---|---|
| committer | Serghei Iakovlev <egrep@protonmail.ch> | 2022-05-31 09:35:31 +0200 |
| commit | 41df0128d69b344050ef12f2dcd884e635a3299f (patch) | |
| tree | af26f956b70c441675023d2105d1ff215458e6a9 /layouts | |
| parent | 882af0656327476b523e0d6538b29ae9ad6eda28 (diff) | |
| download | gohugo-theme-ed-41df0128d69b344050ef12f2dcd884e635a3299f.tar.gz | |
Add tagging support
Diffstat (limited to 'layouts')
| -rw-r--r-- | layouts/_default/list.html (renamed from layouts/_default/list.html.html) | 1 | ||||
| -rw-r--r-- | layouts/_default/single.html | 4 | ||||
| -rw-r--r-- | layouts/_default/term.html | 26 | ||||
| -rw-r--r-- | layouts/partials/post-meta/date.html | 21 | ||||
| -rw-r--r-- | layouts/partials/post-tags.html | 9 | ||||
| -rw-r--r-- | layouts/partials/title.html | 2 |
6 files changed, 53 insertions, 10 deletions
diff --git a/layouts/_default/list.html.html b/layouts/_default/list.html index fc39714..0dd32b6 100644 --- a/layouts/_default/list.html.html +++ b/layouts/_default/list.html @@ -1,7 +1,6 @@ {{ define "main" }} <div class="articles"> - {{/* Render category name if any */}} {{ with .Title }}<h1 class="page-title">{{ . }}</h1>{{ end }} {{/* Render category content if any */}} diff --git a/layouts/_default/single.html b/layouts/_default/single.html index 6b2c851..56557e5 100644 --- a/layouts/_default/single.html +++ b/layouts/_default/single.html @@ -13,5 +13,9 @@ <div class="post-body"> {{ .Content }} </div> + + <div class="post-tags-wrapper"> + {{ partial "post-tags.html" . }} + </div> </article> {{ end }} diff --git a/layouts/_default/term.html b/layouts/_default/term.html new file mode 100644 index 0000000..6ad5d40 --- /dev/null +++ b/layouts/_default/term.html @@ -0,0 +1,26 @@ +{{ define "main" }} + +<div class="articles"> + {{/* TODO: Translate me */}} + <h1 class="page-title"> + {{ with .Title }}{{ i18n "publications_tagged" . }}{{ end }} + </h1> + + {{/* Render category content if any */}} + {{ with .Content }} + <div class="section-content"> + {{ .Content }} + </div> + {{ end }} + + {{/* Render posts list */}} + <div class="post-list"> + {{ range .Paginator.Pages }} + {{ .Render "teaser" }} + {{ end }} + + {{- partial "pagination.html" . -}} + </div> +</div> + +{{ end }} diff --git a/layouts/partials/post-meta/date.html b/layouts/partials/post-meta/date.html index 04a814a..e5626cf 100644 --- a/layouts/partials/post-meta/date.html +++ b/layouts/partials/post-meta/date.html @@ -1,11 +1,14 @@ -{{ if not .Date.IsZero }} - <time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}"> - {{ .Date | time.Format (site.Params.dateformat | default "January 02, 2006") }} - </time> +{{ $date := .Date | time.Format (site.Params.dateformat | default "January 02, 2006") }} +{{ $lastmod := .Lastmod | time.Format (site.Params.dateformat | default "January 02, 2006") }} + +<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z07:00" }}"> + {{ $date }} +</time> - {{ if ne .Date .Lastmod }} - <time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}"> - ({{ i18n "updated_at" }} {{ .Lastmod | time.Format (site.Params.dateformat | default "January 02, 2006") }}) - </time> - {{ end }} +{{/* Check that lastmod exists and is greater than date + (i.e. the last modified date must be after the publish date) */}} +{{ if and (ne $lastmod $date) (gt .Lastmod .Date) }} + <time datetime="{{ .Lastmod.Format "2006-01-02T15:04:05Z07:00" }}"> + ({{ i18n "updated_at" }} {{ $lastmod }}) + </time> {{ end }} diff --git a/layouts/partials/post-tags.html b/layouts/partials/post-tags.html new file mode 100644 index 0000000..1fa1c96 --- /dev/null +++ b/layouts/partials/post-tags.html @@ -0,0 +1,9 @@ +{{ $tags := .Params.Tags | default slice }} + +<ul class="post-tags"> + {{ range $index, $name := sort $tags -}} + <a href="{{ (printf "/tags/%s/" $name) | urlize }}"> + {{ $name | markdownify }} + </a> + {{ end }} +</ul> diff --git a/layouts/partials/title.html b/layouts/partials/title.html index 76cfb2f..b3754ba 100644 --- a/layouts/partials/title.html +++ b/layouts/partials/title.html @@ -1,5 +1,7 @@ {{- if or .IsHome (eq .Title site.Title) -}} {{- site.Title -}} +{{- else if and (eq .Kind "term") (eq .Data.Singular "tag") -}} + {{- with .Title }}{{ i18n "publications_tagged" . }} - {{ end }}{{ site.Title -}} {{- else -}} {{- with .Title }}{{ . }} - {{ end }}{{ site.Title -}} {{- end -}} |
