refactor: split single header and meta components into partials

This commit is contained in:
Ben Goldsworthy 2025-01-27 23:34:33 +01:00
parent d0577aec91
commit e6889cabba
No known key found for this signature in database
22 changed files with 742 additions and 406 deletions

View file

@ -0,0 +1,33 @@
{{- /*
Renders the automatic warnings for an item.
@params pc The page context.
*/
-}}
{{ $post_age_in_years := math.Round ( div ( div ( now.Sub .pc.PublishDate ).Hours 24 ) 365 ) }}
{{ if ( or .pc.Params.site .pc.Params.controversial ( gt $post_age_in_years 2 ) ) }}
<aside class="article-header__warnings">
<ul>
{{ if ( gt $post_age_in_years 2 ) }}
<li>
This piece was written <strong>over {{ $post_age_in_years }} years ago</strong>. It may no longer accurately reflect my views now,
or may be factually outdated.
</li>
{{ end }}
{{ if .pc.Params.controversial }}
<li>
This piece has been marked as potentially <strong>controversial</strong>, whether due to the topic addressed, the content of the
article, or both. Don't say you weren't warned.
</li>
{{ end }}
{{ if .pc.Params.site }}
<li>
This piece was originally written for an older version of this site. As such, it may not have transferred over properly and some
images and links might be broken.
</li>
{{ end }}
</ul>
</aside>
{{ end }}