archive: improve templating logic

This commit is contained in:
John Bowdre 2024-06-01 22:00:46 -05:00
parent 88427c2888
commit b1625931be

View file

@ -11,82 +11,60 @@
<i>My collection of <a target="_blank" title="what's a slashpage?" href="https://slashpages.net">slash pages</a>.</i><hr> <i>My collection of <a target="_blank" title="what's a slashpage?" href="https://slashpages.net">slash pages</a>.</i><hr>
{{ else }} {{ else }}
<h1>{{ .Title | markdownify }}{{ if eq .Kind "term" }}&nbsp;<a target="_blank" href="{{ .Permalink }}feed.xml" aria-label="{{ .Title }} RSS" title="{{ .Title }} RSS"><i class="fa-solid fa-square-rss"></i></a>&nbsp;</h1> <h1>{{ .Title | markdownify }}{{ if eq .Kind "term" }}&nbsp;<a target="_blank" href="{{ .Permalink }}feed.xml" aria-label="{{ .Title }} RSS" title="{{ .Title }} RSS"><i class="fa-solid fa-square-rss"></i></a>&nbsp;</h1>
{{ with .Description }}<i>{{ . }}</i><hr>{{ else }}<br>{{ end }} {{ with .Description }}<i>{{ . }}</i>{{ end }}
{{ end }} {{ end }}
<hr>
{{ end }}{{ end }} {{ end }}{{ end }}
{{ .Content }} {{ .Content }}
</header> </header>
{{- if and (eq .Kind "taxonomy") (eq .Title "Tags") }}
{{- if eq .Kind "taxonomy" }} {{/* /tags/ */}}
{{- if eq .Title "Tags" }} <div class="tagsArchive">
{{/* list of all tags */}} {{- range $key, $value := .Site.Taxonomies }}
<div class="tagsArchive"> {{- $slicedTags := ($value.ByCount) }}
{{- range $key, $value := .Site.Taxonomies }} {{- range $slicedTags }}
{{- $slicedTags := ($value.ByCount) }} {{- if eq $key "tags"}}
{{- range $slicedTags }} <div><a href='/{{ $key }}/{{ (replace .Name "#" "%23") | urlize }}/' title="{{ .Name }}">{{ .Name }}</a><sup>{{ .Count }}</sup></div>
{{- if eq $key "tags"}}
<div><a href='/{{ $key }}/{{ (replace .Name "#" "%23") | urlize }}/' title="{{ .Name }}">{{ .Name }}</a><sup>{{ .Count }}</sup></div>
{{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
</div>
{{- else }}
{{/* list of all categories */}}
{{- range .Pages.ByDate.Reverse }}
{{- $postDate := .Date.Format "2006-01-02" }}
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
<article class="post">
<header class="post__header">
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
<p class="post__meta">
<span class="date">["{{ with $updateDate }}{{ . }}{{ else }}{{ $postDate }}{{ end }}"]</span>
</p>
</header>
<section class="post__summary">
{{ .Description }}
</section>
<hr>
</article>
{{ end }}
{{- end }} {{- end }}
{{- else }} </div>
{{- if eq .Title "/slashes" }} {{- else if or (eq .Kind "taxonomy") (eq .Title "/slashes") }}
{{/* slash page archive */}} {{/* /categories/ or /slashes/ */}}
{{- $sortedSlashes := sort $pages "Title" }} {{- $sorted := sort $pages "Title" }}
{{- range $sortedSlashes }} {{- range $sorted }}
{{- $postDate := .Date.Format "2006-01-02" }}
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
<article class="post">
<header class="post__header">
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
<p class="post__meta">
<span class="date">["{{ with $updateDate }}{{ . }}{{ else }}{{ $postDate }}{{ end }}"]</span>
</p>
</header>
<section class="post__summary">
{{ .Description }}
</section>
<hr>
</article>
{{- end }}
{{- else }}
{{/* regular posts archive */}}
{{- range (.Paginate $pages).Pages }}
{{- $postDate := .Date.Format "2006-01-02" }} {{- $postDate := .Date.Format "2006-01-02" }}
{{- $updateDate := .Lastmod.Format "2006-01-02" }} {{- $updateDate := .Lastmod.Format "2006-01-02" }}
<article class="post"> <article class="post">
<header class="post__header"> <header class="post__header">
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1> <h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
<p class="post__meta"> <p class="post__meta">
<span class="date">["{{- $postDate }}"{{- if ne $postDate $updateDate }}, "{{ $updateDate }}"{{ end }}]</span> <span class="date">["{{ with $updateDate }}{{ . }}{{ else }}{{ $postDate }}{{ end }}"]</span>
</p> </p>
</header> </header>
<section class="post__summary"> <section class="post__summary">
{{if .Description }}{{ .Description }}{{ else }}{{ .Summary }}{{ end }} {{ .Description }}
</section>
<hr>
</article>
{{ end }}
{{- else }}
{{/* regular posts archive */}}
{{- range (.Paginate $pages).Pages }}
{{- $postDate := .Date.Format "2006-01-02" }}
{{- $updateDate := .Lastmod.Format "2006-01-02" }}
<article class="post">
<header class="post__header">
<h1><a href="{{ .Permalink }}">{{ .Title | markdownify }}</a></h1>
<p class="post__meta">
<span class="date">["{{- $postDate }}"{{- if ne $postDate $updateDate }}, "{{ $updateDate }}"{{ end }}]</span>
</p>
</header>
<section class="post__summary">
{{if .Description }}{{ .Description }}{{ else }}{{ .Summary }}{{ end }}
</section> </section>
<hr> <hr>
</article> </article>
{{- end }}
{{- template "_internal/pagination.html" . }}
{{- end }} {{- end }}
{{- template "_internal/pagination.html" . }}
{{- end }} {{- end }}