List references at end of archive

This commit is contained in:
David Eisinger
2025-01-10 22:35:09 -05:00
parent 30cd4499f3
commit 749435298e
2 changed files with 38 additions and 21 deletions

View File

@@ -1,20 +1,26 @@
{{ define "main" }}
{{ $sd := .Params.start_date }}
{{ $ed := .Params.end_date }}
{{ $start_date := .Params.start_date }}
{{ $end_date := .Params.end_date }}
<section class="page-break">
{{ time.Format "January 2006" $sd }} {{ time.Format "January 2006" $ed }}
</section>
{{ $dispatches := slice }}
{{ range (sort (.Site.RegularPages.RelatedTo (keyVals "tags" "dispatch")) "Date" "asc") }}
{{ if lt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $sd) }}
{{ if lt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $start_date) }}
{{ continue }}
{{ end }}
{{ if gt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $ed) }}
{{ if gt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $end_date) }}
{{ continue }}
{{ end }}
{{ $dispatches = $dispatches | append . }}
{{ end }}
<section class="page-break">
Dispatches, {{ time.Format "January 2006" $start_date }} {{ time.Format "January 2006" $end_date }}
</section>
{{ range $dispatches }}
<section class="page-break">
<h2>
<a href="{{ .RelPermalink }}">{{ .Title }}</a>
@@ -24,7 +30,31 @@
Posted {{ .Date | time.Format "2006-01-02" }}
</h3>
{{ replaceRE `<audio controls src="((.*)/(.*).mp3)"></audio>` "<a href=\"$1\">$3</a>" .Content | safeHTML }}
{{ replaceRE `<audio controls src="((.*)/(.*).mp3)"></audio>` "<a href=\"$1\">$3</a> ($1)" .Content | safeHTML }}
</section>
{{ end }}
{{ $linkRE := `(?s)<a[^>]+?href="(.+?)"[^>]*?>.*?</a>` }}
<h2>References</h2>
{{ range $dispatches }}
<p>{{ .Title }}</p>
<ol>
<li>{{ .RelPermalink }}</li>
{{ range findRE $linkRE .Content }}
{{ if findRE `<img` . }}
{{ continue }}
{{ end }}
{{ if findRE `href="#` . }}
{{ continue }}
{{ end }}
<li>{{ replaceRE $linkRE "$1" . }}</li>
{{ end }}
</ol>
{{ end }}
{{ end }}