Použít parametr "eventdate" u stránek typu "event"

This commit is contained in:
Marek Nečada 2023-03-26 12:58:03 +03:00
parent 5dc7866d5c
commit e43f73ab95
2 changed files with 17 additions and 2 deletions

View File

@ -11,7 +11,14 @@
<div class="flex">
<a href="{{ .Permalink }}" class="truncate">{{ .Title }}</a>
{{ if eq .Kind "page" }}
<time class="nowrap" datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}">{{ .Date.Format "2. 1. 2006" }}</time>
{{ if eq .Type "event" -}}
{{ with .Params.eventdate }}
{{ $d := . | time.AsTime }}
<time class="nowrap" datetime="{{ $d.Format "2006-01-02T15:04:05Z0700" }}">{{ $d.Format "2. 1. 2006" }}</time>
{{ end }}
{{- else }}
<time class="nowrap" datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}">{{ .Date.Format "2. 1. 2006" }}</time>
{{- end }}
{{ end }}
</div>
</li>

View File

@ -4,11 +4,19 @@
<h1 class="title">{{ .Title }}</h1>
{{ with .Params.tagline }}<span class="tagline">{{ . }}</span>{{ end }}
{{ if ne .Type "page" -}}
{{ if not (in (slice "page" "event") .Type) -}}
<div class="post-date">
<time datetime="{{ .Date.Format "2006-01-02T15:04:05Z0700" }}">{{ .Date.Format "2. 1. 2006" }}</time>
</div>
{{- end }}
{{ if eq .Type "event" -}}
{{ with .Params.eventdate }}
{{ $d := . | time.AsTime }}
<div class="event-date">
<time datetime="{{ $d.Format "2006-01-02T15:04:05Z0700" }}">{{ $d.Format "2. 1. 2006" }}</time>
</div>
{{ end }}
{{- end}}
<div>
{{ .Content }}