1
0
Fork 0
mirror of https://git.sr.ht/~seirdy/seirdy.one synced 2024-11-23 12:52:10 +00:00

Fix post-meta partial

Instead of scratch variables, pass an additional variable into the
template context
This commit is contained in:
Rohan Kumar 2024-03-18 17:55:53 -04:00
parent 83a081438b
commit d3081ddc8a
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
3 changed files with 13 additions and 13 deletions

View file

@ -24,7 +24,7 @@
</a>
</h2>
{{- .Scratch.Set "shortMeta" true -}}
{{- partial "post-meta/post-meta.html" . }}
{{- partial "post-meta/post-meta.html" (dict "context" . "isList" true) }}
{{- if eq .Section "notes" }}
<div class="e-content entry-content" itemprop="articleBody">
{{- if .Params.replyURI -}}

View file

@ -1,7 +1,7 @@
<header>
<h1 itemprop="name headline" class="p-name entry-title" id="h1" tabindex="-1">{{ .Title }}</h1>
{{- if not .Params.disableMeta -}}
{{- partial "post-meta/post-meta.html" . -}}
{{- partial "post-meta/post-meta.html" (dict "context" . "isList" false) -}}
{{- end -}}
</header>
<hr />

View file

@ -1,22 +1,22 @@
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" -}}
{{- $canonicalRelPermalink := .context.RelPermalink | replaceRE "^/~seirdy/" "/" -}}
{{- $isNotes := false -}}
{{- $action := "Posted" -}}
{{- $shortMeta := false -}}
{{- $logURL := printf "%scontent/%s" .Site.Params.logUrlPrefix .File.Path -}}
{{- if .Scratch.Get "shortMeta" -}}
{{- $logURL := printf "%scontent/%s" .context.Site.Params.logUrlPrefix .context.File.Path -}}
{{- if .context.Scratch.Get "shortMeta" -}}
{{- $shortMeta = true -}}
{{- end -}}
{{- if or (eq .Page.Section "notes") (eq .Page.Title "Notes") -}}
{{- if or (eq .context.Page.Section "notes") (eq .context.Page.Title "Notes") -}}
{{- $isNotes = true -}}
{{- $action = "Noted" -}}
{{- end -}}
{{- $needsModTime := gt (sub .Lastmod.Unix .Date.Unix) 900 -}}
{{- $needsModTime := gt (sub .context.Lastmod.Unix .context.Date.Unix) 900 -}}
{{- $needsList := or (and (not $shortMeta) $needsModTime) (not $isNotes) -}}
{{- $gemini := "" }}
{{- with .OutputFormats.Get "gemtext" -}}
{{- with .context.OutputFormats.Get "gemtext" -}}
{{- $gemini = replace .Permalink "/gemini" "" 1 | safeURL -}}
{{- end -}}
{{- if not (eq .Page.Section "posts" ) -}}
{{- if not (eq .context.Page.Section "posts" ) -}}
{{- $gemini = replace $gemini "/index.gmi" ".gmi" | safeURL -}}
{{- end -}}
{{- if $needsList }}
@ -25,16 +25,16 @@
<p>
{{- end }}
{{ if $needsList }}<li>{{ end }}
{{- $action }} <time{{ if not (.Params.evergreen) }} itemprop="dateCreated datePublished" class="dt-published published"{{ end }} datetime="{{ .Date.UTC.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Date.UTC.Format "2006-01-02" }}</time> by {{ partialCached "indieweb-author.html" . -}}{{ if not $shortMeta }} on his <a rel="canonical" itemprop="url" class="u-url url" href="{{ .Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">Website</a>{{- with .OutputFormats.Get "gemtext" -}}{{- printf " " -}}and <a rel="syndication" class="u-syndication" href="{{ $gemini }}">Gemini capsule</a>{{ end }}{{- end -}}.
{{- $action }} <time{{ if not (.context.Params.evergreen) }} itemprop="dateCreated datePublished" class="dt-published published"{{ end }} datetime="{{ .context.Date.UTC.Format "2006-01-02T15:04:05Z07:00" }}">{{ .context.Date.UTC.Format "2006-01-02" }}</time> by {{ partialCached "indieweb-author.html" .context -}}{{ if not .isList }} on his <a rel="canonical" itemprop="url" class="u-url url" href="{{ .context.Site.Params.CanonicalBaseURL }}{{ $canonicalRelPermalink }}">Website</a>{{- with .context.OutputFormats.Get "gemtext" -}}{{- printf " " -}}and <a rel="syndication" class="u-syndication" href="{{ $gemini }}">Gemini capsule</a>{{ end }}{{- end -}}.
{{ if $needsList }}</li>{{ end }}
{{- if gt (sub .Lastmod.Unix .Date.Unix) 900 -}}
{{- if gt (sub .context.Lastmod.Unix .context.Date.Unix) 900 -}}
{{ if $needsList }}<li>{{ end }}
Last updated <time itemprop="dateModified" class="dt-updated updated" datetime="{{ .Lastmod.UTC.Format "2006-01-02T15:04:05Z07:00" }}">{{ .Lastmod.UTC.Format "2006-01-02" }}</time>.{{ if not $shortMeta }} <a href="{{ $logURL }}">Changelog</a>{{ end }}
Last updated <time itemprop="dateModified" class="dt-updated updated" datetime="{{ .context.Lastmod.UTC.Format "2006-01-02T15:04:05Z07:00" }}">{{ .context.Lastmod.UTC.Format "2006-01-02" }}</time>.{{ if not .isList }} <a href="{{ $logURL }}">Changelog</a>{{ end }}
{{ if $needsList }}</li>{{ end }}
{{- end -}}
{{- if not $isNotes -}}
{{ if $needsList }}<li>{{ else }}<br />{{ end }}
{{ partial "post-meta/wordcount.html" . -}}
{{ partial "post-meta/wordcount.html" .context -}}
{{ if $needsList }}</li>{{ end }}
{{- end -}}
{{- if $needsList }}