properly format metadata and previous and next pages

This commit is contained in:
Peter 2025-03-19 13:19:37 -04:00
parent 94d498f0e1
commit b31611af40
4 changed files with 32 additions and 17 deletions

View file

@ -11,15 +11,9 @@
{{ if .Params.showMetadata | default true }} {{ if .Params.showMetadata | default true }}
<section class="postMetadata"> <section class="postMetadata">
<dl> <dl>
{{ with .GetTerms "tags" }}
{{ partial "taxonomy/tags.html" . }}
{{ end }}
{{ with .GetTerms "authors" }} {{ with .GetTerms "authors" }}
{{ partial "taxonomy/authors.html" . }} {{ partial "taxonomy/authors.html" . }}
{{ end }} {{ end }}
{{ with .GetTerms "categories" }}
{{ partial "taxonomy/categories.html" . }}
{{ end }}
{{ if .Site.Params.published | default true }} {{ if .Site.Params.published | default true }}
<dt>{{ i18n "published" }}</dt> <dt>{{ i18n "published" }}</dt>
{{ $formattedDate := .Date.Format "2006-01-02" }} {{ $formattedDate := .Date.Format "2006-01-02" }}
@ -29,16 +23,14 @@
<dt>{{ i18n "reading_time" }}</dt> <dt>{{ i18n "reading_time" }}</dt>
<dd>{{ i18n "reading_time_desc" .ReadingTime }}</dd> <dd>{{ i18n "reading_time_desc" .ReadingTime }}</dd>
{{ end }} {{ end }}
{{ with .GetTerms "categories" }}
{{ partial "taxonomy/categories.html" . }}
{{ end }}
{{ with .GetTerms "tags" }}
{{ partial "taxonomy/tags.html" . }}
{{ end }}
</dl> </dl>
{{ $pages := .CurrentSection.Pages.ByWeight }} {{ template "partials/prev-next.html" . }}
{{ with $pages.Prev . }}
<a href="{{ .RelPermalink }}">« Entrada anterior</a>
{{ end }}
/
{{ with $pages.Next . }}
<a href="{{ .RelPermalink }}">Entrada siguiente »</a>
{{ end }}
</section> </section>
{{ end }} {{ end }}
<div> <div>
@ -66,9 +58,11 @@
{{ end }} {{ end }}
</ul> </ul>
{{ end }} {{ end }}
</section>
</br> </br>
</div> </div>
</div> </div>
</br> </br>
</div> </div>
{{ end }} {{ end }}

View file

@ -25,7 +25,7 @@
<!-- [html-validate-disable-next prefer-native-element] --> <!-- [html-validate-disable-next prefer-native-element] -->
<div class="postListItem" role="listitem"> <div class="postListItem" role="listitem">
<div class="postHeader"> <div class="postHeader">
<span class="postTitle">{{ .Title }}</span> <span class="postTitle">{{ .Title }}</span></a>
{{ $formattedDate := .Date.Format "2006-01-02" }} {{ $formattedDate := .Date.Format "2006-01-02" }}
<time class="postDate" datetime="{{ $formattedDate }}">{{ .Date | time.Format ":date_long" }}</time> <time class="postDate" datetime="{{ $formattedDate }}">{{ .Date | time.Format ":date_long" }}</time>
</div> </div>
@ -33,7 +33,7 @@
<p>{{ .Summary }}</p> <p>{{ .Summary }}</p>
</div> </div>
</div> </div>
</a>
{{ range .Pages.ByWeight }} {{ range .Pages.ByWeight }}
<h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2> <h2><a href="{{ .RelPermalink }}">{{ .LinkTitle }}</a></h2>
{{ end }} {{ end }}

View file

@ -0,0 +1,13 @@
{{ $pages := .CurrentSection.Pages.ByDate.Reverse }}
{{ with $pages.Prev . }}
<a href="{{ .RelPermalink }}">« Entrada anterior</a>
{{ else }}
{{ print "« Entrada anterior" }}
{{ end }}
<span>|</span>
{{ with $pages.Next . }}
<a href="{{ .RelPermalink }}">Entrada siguiente »</a>
{{ else }}
{{ print "Entrada siguiente »" }}
{{ end }}

View file

@ -0,0 +1,8 @@
<!-- [html-validate-disable element-required-ancestor] -->
<dt>{{ i18n "categories" }}</dt>
<dd>
{{- range $index, $el := . -}}
<span> /</span>
<a href="{{ .RelPermalink }}">{{- .LinkTitle -}}</a>
{{- end -}}
</dd>