mirror of
https://github.com/ItsDrike/itsdrike.com.git
synced 2024-11-10 05:59:41 +00:00
ItsDrike
b444f03185
We previously used .Scratch which is a global scratchpad, that was later passed over to the partial with the rest of the context. The partial then checked if this value was set, and had a fallback if it wasn't (default value). This approach does work in most of the cases, however in about 5% of runs, it fails. I assume this is due to hugo spinning up multiple threads, and each of them is changing this global scratchpad in arbitrary order. At some point, a thread then removed this value from the scratchpad to reset it, but another thread already checked that this variable does exist, and has now set the no longer available variable. To avoid this, we can instead directly pass a custom dict, which contains the original context (.) along with another variable, which will hold the dateformat. This however means that we can't use the simple syntax with a default value, and the dateformat will need to be set each time (though technically, it could be set to nil and checked later, but if we're already specifying it, we may as well pass in this dateformat directly)
39 lines
1.3 KiB
HTML
39 lines
1.3 KiB
HTML
{{ define "main" }}
|
|
<div id="main">
|
|
<div class="container">
|
|
<!-- TODO:
|
|
- Mention total post amt
|
|
- Total words across posts
|
|
- link to tag list page (and maybe remove link from content-details),
|
|
- Link for Hugo generated RSS
|
|
-->
|
|
|
|
<div class="item-list">
|
|
{{ partial "content.html" . }}
|
|
<!-- Go through post groups by year -->
|
|
{{ range .Data.Pages.GroupByDate "2006" }}
|
|
{{ $year := .Key }}
|
|
|
|
<div class="item-list-group">
|
|
<!-- Show the year for this group -->
|
|
<h3 class="item-list-year" id="{{ $year }}">
|
|
<a href="#{{ $year }}">
|
|
<time datetime="{{ $year }}" title='{{ $year }}'>{{ $year }}</time>
|
|
</a>
|
|
</h3>
|
|
|
|
<!-- List all posts in this year group -->
|
|
<ul class="item-list-items">
|
|
{{ range .Pages }}
|
|
<li class="item-list-item" data-id="{{ with .File}}{{ .File.UniqueID }}{{ end }}">
|
|
{{ partial "list_item.html" (dict "context" . "dateformat" "Jan 02") }}
|
|
</li>
|
|
{{ end }}
|
|
</ul>
|
|
</div>
|
|
{{ end }}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{{ end }}
|