diff options
Diffstat (limited to 'layouts/partials')
| -rw-r--r-- | layouts/partials/recent.html | 15 | ||||
| -rw-r--r-- | layouts/partials/updated-items.html | 16 |
2 files changed, 19 insertions, 12 deletions
diff --git a/layouts/partials/recent.html b/layouts/partials/recent.html index 47c8332..cbe91af 100644 --- a/layouts/partials/recent.html +++ b/layouts/partials/recent.html @@ -1,18 +1,8 @@ -{{- $items := slice -}} -{{- range where site.RegularPages "Section" "journal" -}} - {{- $items = $items | append (dict "page" . "kind" "journal" "sortDate" (.Date.Format "2006-01-02")) -}} -{{- end -}} -{{- range where site.RegularPages "Section" "notes" -}} - {{- $page := . -}} - {{- with $page.Params.recent -}} - {{- $items = $items | append (dict "page" $page "kind" "note" "sortDate" (time.Format "2006-01-02" .)) -}} - {{- end -}} -{{- end -}} -{{- $items = sort $items "sortDate" "desc" -}} +{{- $items := partial "updated-items.html" . -}} <section class="recent" aria-labelledby="recent-title"> <h2 id="recent-title">RECENT</h2> <ol class="document-list"> - {{- range $items }} + {{- range first site.Params.recentLimit $items }} <li> <time datetime="{{ .sortDate }}">{{ .sortDate }}</time> <span class="document-kind">[{{ .kind }}]</span> @@ -20,4 +10,5 @@ </li> {{- end }} </ol> + <p class="recent-more"><a href="{{ "updates/" | relURL }}">Read more</a></p> </section> diff --git a/layouts/partials/updated-items.html b/layouts/partials/updated-items.html new file mode 100644 index 0000000..5f738a8 --- /dev/null +++ b/layouts/partials/updated-items.html @@ -0,0 +1,16 @@ +{{- $items := slice -}} +{{- range $section := slice "journal" "notes" -}} + {{- $kind := cond (eq $section "notes") "note" "journal" -}} + {{- range where site.RegularPages "Section" $section -}} + {{- if not .Params.created -}} + {{- errorf "Missing required created date in %s" .File.Path -}} + {{- end -}} + {{- if not .Params.updated -}} + {{- errorf "Missing required updated date in %s" .File.Path -}} + {{- end -}} + {{- $sortDate := time.Format "2006-01-02" .Params.updated -}} + {{- $sortKey := printf "%s|%s" $sortDate .RelPermalink -}} + {{- $items = $items | append (dict "page" . "kind" $kind "sortDate" $sortDate "sortKey" $sortKey) -}} + {{- end -}} +{{- end -}} +{{- return (sort $items "sortKey" "desc") -}} |
