Add partial caching for speed bump

This commit is contained in:
JP Hastings-Spital 2024-10-11 10:17:16 +01:00
parent f686d99756
commit 6f2ca586a7
17 changed files with 35 additions and 39 deletions

View file

@ -9,7 +9,7 @@
{{ end }}
<div class="container">
{{ partial "header.html" . }}
{{ partialCached "header.html" . }}
<div class="content">
{{ block "main" . }}{{ end }}

View file

@ -86,7 +86,7 @@
{{ if .Page.Store.Get "hasSpoilers" }}
<blockquote class="spoiler-explainer">
{{ partial "svg.html" (dict "name" "hidden") }} This post contains spoilers, but they're hidden by default.
{{ partialCached "svg.html" (dict "name" "hidden") "hidden" }} This post contains spoilers, but they're hidden by default.
</blockquote>
{{ end }}
@ -110,17 +110,17 @@
{{ if in .Params.tags "from-twitter" }}
<p>
{{ partial "svg.html" (dict "name" "twitter") }}
{{ partialCached "svg.html" (dict "name" "twitter") "twitter" }}
From <a href="/posts/importing-tweets">twitter archive</a>
</p>
{{ else if in .Params.tags "from-facebook" }}
<p>
{{ partial "svg.html" (dict "name" "facebook") }}
{{ partialCached "svg.html" (dict "name" "facebook") "facebook" }}
From <a href="/notes/facebook/">facebook archive</a>
</p>
{{ else if in .Params.tags "from-goodreads" }}
<p>
{{ partial "svg.html" (dict "name" "goodreads") }}
{{ partialCached "svg.html" (dict "name" "goodreads") "goodreads" }}
From <a href="/tags/from-goodreads/#">goodreads archive</a>
</p>
{{ end }}

View file

@ -29,7 +29,7 @@
<div class="post-content p-description" data-pagefind-body data-pagefind-filter="type:{{.Type | title}}">
{{ if not $event.isPast }}
<p class="next-visit">
{{ partial "svg.html" (dict "name" "calendar") }} I'm planning on going to this event on {{ partial "year-relative-date.html" (slice (time.AsTime $event.timing.starts) "dt-start") }}.
{{ partialCached "svg.html" (dict "name" "calendar") "calendar" }} I'm planning on going to this event on {{ partial "year-relative-date.html" (slice (time.AsTime $event.timing.starts) "dt-start") }}.
See the bottom of the post for more information.
</p>
{{ end }}
@ -75,7 +75,7 @@
{{ if $event.timing.attending }}
<p class="attending">
{{ partial "svg.html" (dict "name" "attending") }}
{{ partialCached "svg.html" (dict "name" "attending") }}
{{ if eq $event.timing.attending true }}{{ partial "friend.html" "jp.no-emoji" }} is going
{{ else if eq (len $event.timing.attending) 1 }}
{{ partial "friend.html" (printf "%s.no-emoji" (index $event.timing.attending 0)) }} is going

View file

@ -23,5 +23,5 @@
{{ partial "post-previews.html" .}}
</section>
</main>
{{ partial "site-last-update.html" }}
{{ partialCached "site-last-update.html" . }}
{{ end }}

View file

@ -25,7 +25,7 @@
{{ .Content }}
<footer>
<a href="{{.RelPermalink}}">{{ partial "year-relative-date.html" .Date }}</a>
{{ if collections.In .Params.tags "from-twitter" }}{{ partial "svg.html" (dict "name" "twitter") }}{{ end }}
{{ if collections.In .Params.tags "from-twitter" }}{{ partialCached "svg.html" (dict "name" "twitter") "twitter" }}{{ end }}
</footer>
</article>
{{ end }}

View file

@ -7,7 +7,7 @@
{{- $target := $page.OutputFormats.Get .Name -}}
{{- $link := $target.RelPermalink -}}
{{- if not (hasPrefix $target.Permalink "http") }}{{ $link = (partial "noindex.gmi" $target.Permalink) }}{{ end -}}
<li><a href="{{ $link | safeURL }}" title="{{ partial "alternatename.txt" .Name }}">{{ partial "svg.html" (dict "name" .Name) }}{{ partial "alternatename.txt" .Name }}</a></li>
<li><a href="{{ $link | safeURL }}" title="{{ partial "alternatename.txt" .Name }}">{{ partialCached "svg.html" (dict "name" .Name) .Name }}{{ partial "alternatename.txt" .Name }}</a></li>
{{- end }}
</ul>
</nav>

View file

@ -3,7 +3,7 @@
{{- $interactionCount := partial "interaction-count.obj" page -}}
<form class="claps" action="https://{{ site.Params.clapsHost }}{{ $relperma }}" method="post">
<button type="submit" title="Show appreciation for the post on this page" data-interactions="{{ $interactionCount }}">
{{- partial "svg.html" (dict "name" $style) -}}
{{- partialCached "svg.html" (dict "name" $style) $style -}}
{{- $url := printf "https://%s" site.Params.clapsHost -}}
{{- $cacheKey := print $url (now.Format "-2006-01-02-15") -}}
{{- with resources.GetRemote $url (dict "key" $cacheKey) -}}

View file

@ -1,5 +1,8 @@
{{- $title := $.Site.Title -}}
{{- if not .IsHome -}}{{ $title = printf "%s, %s" (partial "page-title.txt" .) $.Site.Title }}{{ end -}}
{{- $modified := .Lastmod -}}
{{- if .IsHome }}{{ with getenv "HUGO_LAST_UPDATE_TIME" }}{{ $modified = time . }}{{ end }}{{ end -}}
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
@ -7,8 +10,6 @@
<meta name="description" content="{{ if .IsHome }}{{ .Site.Params.homeSubtitle }}{{ else }}{{ if .Params.Description }}{{ .Params.Description }}{{ else }}{{ .Summary | plainify }}{{ end }}{{ end }}" class="p-summary"/>
<meta name="keywords" content="{{ .Site.Params.keywords }}{{ if .Params.tags }}{{ range .Params.tags }}, {{ . }}{{ end }}{{ end }}"/>
<meta name="theme-color" content="{{ .Site.Params.themeColor }}"/>
{{- $modified := .Lastmod -}}
{{- if .IsHome }}{{ with getenv "HUGO_LAST_UPDATE_TIME" }}{{ $modified = time . }}{{ end }}{{ end -}}
<meta property="dcterms.modified" content="{{ $modified.Format "2006-01-02T15:04:05Z07:00"}}"/>
<link rel="canonical" href="{{ .Permalink }}" class="u-url"/>
{{ with partial "shortlink.txt" . -}}
@ -37,17 +38,13 @@
{{- end -}}
</title>
{{- end }}
<link href="/css/postcards.css" rel="stylesheet" type="text/css">
{{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "enableSourceMap" true) }}
{{ $style := resources.Get "scss/main.scss" | resources.ToCSS $options | resources.Fingerprint }}
{{ $options := (dict "targetPath" "main.css" "outputStyle" "compressed" "enableSourceMap" true) -}}
{{ $style := resources.Get "scss/main.scss" | resources.ToCSS $options | resources.Fingerprint -}}
<link rel="stylesheet" href="{{ $style.RelPermalink }}">
{{ range $val := $.Site.Params.customCSS }}
{{ if gt (len $val) 0 }}
<link rel="stylesheet" type="text/css" href="{{ $val }}">
{{ end }}
{{ range $val := $.Site.Params.customCSS -}}
{{ if le (len $val) 0 }}{{ continue }}{{ end -}}
<link rel="stylesheet" type="text/css" href="{{ $val }}">
{{ end }}
<!-- Icons -->
@ -71,4 +68,3 @@
{{- if templates.Exists "partials/extra-head.html" -}}
{{ partial "extra-head.html" . }}
{{- end }}

View file

@ -2,7 +2,7 @@
<ul class="menu__inner">
{{- $page := .Page -}}
{{ range .Site.Menus.main -}}
<li class="micro{{ if hasPrefix $page.RelPermalink .URL }} active{{ end }}"><a href="{{ .URL }}" title="{{ .Name }}">{{ partial "svg.html" (dict "name" (index site.Params.defaultSVG (.Identifier | singularize))) }}<span> {{ .Name }}</span></a></li>
<li class="micro{{ if hasPrefix $page.RelPermalink .URL }} active{{ end }}"><a href="{{ .URL }}" title="{{ .Name }}">{{ partialCached "svg.html" (dict "name" (index site.Params.defaultSVG (.Identifier | singularize))) .Identifier }}<span> {{ .Name }}</span></a></li>
{{- end }}
</ul>
</nav>

View file

@ -7,7 +7,7 @@
{{- $postType := partial "post-type.txt" . -}}
{{- $typeSVG := index .Site.Params.defaultSVG ( partial "kebab.txt" ($postType | singularize)) -}}
<li>
{{ partial "svg.html" (dict "name" $typeSVG) }}
{{ partialCached "svg.html" (dict "name" $typeSVG) $typeSVG }}
<a href="{{.RelPermalink}}">
{{- with .Title -}}{{ . }}{{ else }}{{ .Type | singularize | title }}{{ end -}}
</a>
@ -25,13 +25,13 @@
{{- end -}}
</ol>
<p class="post-content">{{ partial "svg.html" (dict "name" "document") }} Check out <a href="/posts">all my longer posts</a>, or read through my <a href="/bookmarks">thoughts on others' writing</a>.</p>
<p class="post-content">{{ partialCached "svg.html" (dict "name" "document") "document" }} Check out <a href="/posts">all my longer posts</a>, or read through my <a href="/bookmarks">thoughts on others' writing</a>.</p>
{{- $upcomingEvents := partial "upcoming-events.obj" }}
{{ if ge (len $upcomingEvents) 2 }}
<hr class="mini" />
<p class="post-content">
{{ partial "svg.html" (dict "name" "calendar") }}
{{ partialCached "svg.html" (dict "name" "calendar") "calendar" }}
Maybe you'll see me at
<a href="{{ (index $upcomingEvents 0).Page.RelPermalink }}">{{ (index $upcomingEvents 0).Title }}</a> on {{ partial "year-relative-date.html" (index $upcomingEvents 0).Date }}, or
<a href="{{ (index $upcomingEvents 1).Page.RelPermalink }}">{{ (index $upcomingEvents 1).Title }}</a> on {{ partial "year-relative-date.html" (index $upcomingEvents 1).Date }}.
@ -45,7 +45,7 @@
{{- $picPage := index (where .Site.RegularPages "Section" "eq" "photos") 0 -}}
{{- with $picPage -}}
<div class="photo">
<div class="context">{{ partial "svg.html" (dict "name" "camera") }} <a href="{{ .RelPermalink }}"><date datetime="{{ dateFormat "2006-01-02T15:04:05-0700" .Date }}" title="Posted on {{ dateFormat "Monday Jan 2 2006 at 03:04 MST" .Date }}" data-pagefind-sort="date">{{ partial "year-relative-date.html" .Date }}</date></a></div>
<div class="context">{{ partialCached "svg.html" (dict "name" "camera") "camera" }} <a href="{{ .RelPermalink }}"><date datetime="{{ dateFormat "2006-01-02T15:04:05-0700" .Date }}" title="Posted on {{ dateFormat "Monday Jan 2 2006 at 03:04 MST" .Date }}" data-pagefind-sort="date">{{ partial "year-relative-date.html" .Date }}</date></a></div>
<figure>
{{- $src := index $picPage.Params.Media 0 -}}
@ -60,7 +60,7 @@
{{- with (partial "latest-non-reply-note.obj") -}}
<div class="note">
<div class="context">{{ partial "svg.html" (dict "name" "message") }} <a href="{{ .RelPermalink }}"><date datetime="{{ dateFormat "2006-01-02T15:04:05-0700" .Date }}" title="Posted on {{ dateFormat "Monday Jan 2 2006 at 03:04 MST" .Date }}" data-pagefind-sort="date">
<div class="context">{{ partialCached "svg.html" (dict "name" "message") "message" }} <a href="{{ .RelPermalink }}"><date datetime="{{ dateFormat "2006-01-02T15:04:05-0700" .Date }}" title="Posted on {{ dateFormat "Monday Jan 2 2006 at 03:04 MST" .Date }}" data-pagefind-sort="date">
{{ partial "year-relative-date.html" .Date }}</date></a>
</div>

View file

@ -11,7 +11,7 @@
{{- $reference = dict "name" (partial "page-title.txt" $other.Page) "type" $other.Page.Type "internal" true -}}
{{- end -}}
{{- end -}}
{{ partial "svg.html" (dict "name" .svg) }} {{ .phrase }}{{" "}}
{{ partialCached "svg.html" (dict "name" .svg) .svg }} {{ .phrase }}{{" "}}
{{- with $reference.name -}}
{{- if $reference.internal -}}my{{else}}the{{end}} {{ partial "article-type.txt" (default "article" $reference.type) }} {{ partial "rich-link.html" (dict "Class" (printf "%s h-cite" $mf2) "url" $url "Text" . "references" $references) }}.
{{- else -}}

View file

@ -1,3 +1,3 @@
{{ range . -}}
&nbsp; <a href="{{ .url }}" target="_blank" rel="{{ if .rel }}{{ .rel }}{{ else }}me noopener{{ end }}" title="{{ .name | humanize }}">{{ partial "svg.html" . }}</a> &nbsp;
&nbsp; <a href="{{ .url }}" target="_blank" rel="{{ if .rel }}{{ .rel }}{{ else }}me noopener{{ end }}" title="{{ .name | humanize }}">{{ partialCached "svg.html" . . }}</a> &nbsp;
{{- end -}}

View file

@ -5,7 +5,7 @@
<a rel="syndication" class="{{ if ne .type "email" }}u-syndication {{ end }}resp-syndication__link" href="{{ .link }}" target="_blank" rel="noopener" title="{{ $title }}">
<div class="resp-syndication resp-syndication--small">
<div aria-hidden="true" class="resp-syndication__icon resp-syndication__icon--solid">
{{ partial "svg.html" (dict "name" .type) }}
{{ partialCached "svg.html" (dict "name" .type) .type }}
</div>
</div>
</a>

View file

@ -1,7 +1,7 @@
{{ $topics := .Params.topics }}
{{ with $topics }}{{ if gt (len $topics) 0 }}
<p>
{{ partial "svg.html" (dict "name" "topic") }}
{{ partialCached "svg.html" (dict "name" "topic") "topic" }}
<span class="topics">
{{ range $i, $topic := . }}

View file

@ -24,12 +24,12 @@
{{ partial "claps.html" (dict "url" .RelPermalink "style" "heart") }}
{{ if in .Params.tags "from-instagram" }}
<p>
{{ partial "svg.html" (dict "name" "instagram") }}
{{ partialCached "svg.html" (dict "name" "instagram") "instagram" }}
From <a href="/posts/archiving-instagram-posts/">instagram archive</a>
</p>
{{ else if in .Params.tags "from-facebook" }}
<p>
{{ partial "svg.html" (dict "name" "facebook") }}
{{ partialCached "svg.html" (dict "name" "facebook") "facebook" }}
From <a href="/notes/facebook/">facebook archive</a>
</p>
{{ end }}

View file

@ -10,8 +10,8 @@
<a href="{{ .RelPermalink }}" class="noaccent u-url">{{ .Title | markdownify }}</a>
</h1>
<ul class="feedlinks">
<li><a href="{{.Params.feed.rss}}" target="_blank" rel="noopener">{{ partial "svg.html" (dict "name" "rss") }}Feed</a></li>
{{ if .Params.feed.url }}<li><a href="{{.Params.feed.url}}" target="_blank" rel="noopener">{{ partial "svg.html" (dict "name" "web") }}Homepage</a></li>{{ end }}
<li><a href="{{.Params.feed.rss}}" target="_blank" rel="noopener">{{ partialCached "svg.html" (dict "name" "rss") "rss" }}Feed</a></li>
{{ if .Params.feed.url }}<li><a href="{{.Params.feed.url}}" target="_blank" rel="noopener">{{ partialCached "svg.html" (dict "name" "web") "web" }}Homepage</a></li>{{ end }}
</ul>
</hgroup>

View file

@ -18,11 +18,11 @@
{{- $postType := partial "post-type.txt" . -}}
{{- $typeSVG := index site.Params.defaultSVG (partial "kebab.txt" ($postType | singularize)) -}}
<li>
{{ partial "svg.html" (dict "name" $typeSVG) }}
{{ partialCached "svg.html" (dict "name" $typeSVG) $typeSVG }}
<a href="{{.RelPermalink}}">
{{- with .Title -}}{{ . }}{{ else }}{{ .Type | singularize | title }}{{ end -}}
</a>
<small style="opacity: 0.6">{{ partial "svg.html" (dict "name" "clap") }} {{ $count }}</small>
<small style="opacity: 0.6">{{ partialCached "svg.html" (dict "name" "clap") "clap" }} {{ $count }}</small>
</li>
{{- end -}}
{{- end }}