davideisinger.com

My personal website
Log | Files | Refs | README

single.html (1552B)


      1 {{ define "main" }}
      2   {{ $start_date := .Params.start_date }}
      3   {{ $end_date := .Params.end_date }}
      4 
      5   {{ $dispatches := slice }}
      6 
      7   {{ range (sort (.Site.RegularPages.RelatedTo (keyVals "tags" "dispatch")) "Date" "asc") }}
      8     {{ if lt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $start_date) }}
      9       {{ continue }}
     10     {{ end }}
     11 
     12     {{ if gt (time.Format "2006-01-02" .Date) (time.Format "2006-01-02" $end_date) }}
     13       {{ continue }}
     14     {{ end }}
     15 
     16     {{ $dispatches = $dispatches | append . }}
     17   {{ end }}
     18 
     19   <section class="page-break">
     20     Dispatches, {{ time.Format "January 2006" $start_date }} – {{ time.Format "January 2006" $end_date }}
     21 
     22     <hr>
     23 
     24     {{ .Content }}
     25   </section>
     26 
     27   {{ range $dispatches }}
     28     <section class="page-break">
     29       <h2>
     30         <a href="{{ .RelPermalink }}">{{ .Title }}</a>
     31       </h2>
     32 
     33       <h3>
     34         Posted {{ .Date | time.Format "2006-01-02" }}
     35       </h3>
     36 
     37       {{ replaceRE `<audio controls src="((.*)/(.*).mp3)"></audio>` "<a href=\"$1\">$3</a> ($1)" .Content | safeHTML }}
     38     </section>
     39   {{ end }}
     40 
     41   {{ $linkRE := `(?s)<a[^>]+?href="(.+?)"[^>]*?>.*?</a>` }}
     42 
     43   <h2>References</h2>
     44 
     45   {{ range $dispatches }}
     46     <p>{{ .Title }}</p>
     47 
     48     <ol>
     49       <li>{{ .RelPermalink }}</li>
     50 
     51       {{ range findRE $linkRE .Content }}
     52         {{ if findRE `<img` . }}
     53           {{ continue }}
     54         {{ end }}
     55 
     56         {{ if findRE `href="#` . }}
     57           {{ continue }}
     58         {{ end }}
     59 
     60         <li>{{ replaceRE $linkRE "$1" . }}</li>
     61       {{ end }}
     62     </ol>
     63   {{ end }}
     64 {{ end }}