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

Split up + organize some large partials

Use partialCached to avoid any perf penalty.
TODO: limit the scope I pass to them.

I noticed a teeny tiny perf improvement after doing this, probably
because now some giant data structures only need to be generated once.
This commit is contained in:
Rohan Kumar 2023-11-25 12:53:36 -08:00
parent 3e3fda3ca2
commit 19d5fe2b00
No known key found for this signature in database
GPG key ID: 1E892DB2A5F84479
13 changed files with 18 additions and 18 deletions

View file

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

View file

@ -28,7 +28,7 @@
</p> </p>
<div> <div>
<p class="p-summary entry-summary" itemprop="description">{{ .Description }}</p> <p class="p-summary entry-summary" itemprop="description">{{ .Description }}</p>
<p>{{- partial "wordcount.html" . -}}</p> <p>{{- partial "post-meta/wordcount.html" . -}}</p>
</div> </div>
</article> </article>
</li> </li>

View file

@ -28,7 +28,7 @@
</p> </p>
<div> <div>
<p class="p-summary entry-summary" itemprop="description">{{ .Description }}</p> <p class="p-summary entry-summary" itemprop="description">{{ .Description }}</p>
<p>{{- partial "wordcount.html" . -}}</p> <p>{{- partial "post-meta/wordcount.html" . -}}</p>
</div> </div>
</article> </article>
</li> </li>

View file

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

View file

@ -3,5 +3,5 @@
<h2 id="interact" tabindex="-1">Interact</h2> <h2 id="interact" tabindex="-1">Interact</h2>
<p>You can interact by <a href="#webmentions">sending webmentions</a> or by visiting a syndicated copy of this post.</p> <p>You can interact by <a href="#webmentions">sending webmentions</a> or by visiting a syndicated copy of this post.</p>
{{- partial "syndication.html" . -}} {{- partial "syndication.html" . -}}
{{- partial "webmentions.html" . -}} {{- partial "webmentions/webmentions.html" . -}}
</footer> </footer>

View file

@ -34,7 +34,7 @@
{{- end -}} {{- end -}}
{{- if not $isNotes -}} {{- if not $isNotes -}}
{{ if $needsList }}<li>{{ else }}<br />{{ end }} {{ if $needsList }}<li>{{ else }}<br />{{ end }}
{{ partial "wordcount.html" . -}} {{ partial "post-meta/wordcount.html" . -}}
{{ if $needsList }}</li>{{ end }} {{ if $needsList }}</li>{{ end }}
{{- end -}} {{- end -}}
{{- if $needsList }} {{- if $needsList }}

View file

@ -27,7 +27,7 @@
<div> <div>
<p class="p-summary entry-summary" itemprop="description">{{ .Description }}</p> <p class="p-summary entry-summary" itemprop="description">{{ .Description }}</p>
<p>{{- partial "wordcount.html" . -}}</p> <p>{{- partial "post-meta/wordcount.html" . -}}</p>
</div> </div>
</article> </article>
</li> </li>

View file

@ -0,0 +1 @@
{{- return (index .Site.Data "webmentions").items -}}

View file

@ -0,0 +1,5 @@
{{- $rewritesDict := dict "" "" -}}
{{- range $i, $r := (getCSV "," "/csv/rewrites.csv") -}}
{{- $rewritesDict = merge $rewritesDict (dict (index $r 0) (index $r 1)) -}}
{{- end -}}
{{- return $rewritesDict -}}

View file

@ -0,0 +1 @@
{{- return (slice "https://si3t.ch/log/2021-04-18-entetes-floc.html" "https://xmpp.org/2021/02/newsletter-02-feburary/" "https://gurlic.com/technology/post/393626430212145157" "https://gurlic.com/technology/post/343249858599059461" "https://www.librepunk.club/@penryn/108411423190214816" "https://benign.town/@josias/108457015755310198" "http://www.tuxmachines.org/node/148146" "https://i.reddit.com/r/web_design/comments/k0dmpj/an_opinionated_list_of_best_practices_for_textual/gdmxy4u/" "https://bbbhltz.space/posts/thoughts-on-tech-feb2021/" "https://jorts.horse/@alice/108477866954580532" "https://brid.gy/comment/mastodon/@Seirdy@pleroma.envs.net/AK7FeQ4h2tUCKNwlXc/AK7GtGkE7JOVgm1Cgi" "https://fosstodon.org/@werwolf/108529382741681838" "https://mastodon.social/@WahbAllat/108986614624476982" "https://linuxrocks.online/@friend/109029028283860044" "https://fosstodon.org/@fullstackthaumaturge/108765040526523487" "https://inhji.de/notes/an-opinionated-list-of-best-practices-for-textual-websites" "https://ravidwivedi.in/whatsapp/" "https://hackers.town/@theruran/108440680870400884" "https://hackers.town/@theruran/108440475936938471" "https://mckinley.cc/twtxt/2022-may-aug.html#2022-06-25T16:06:07-07:00" "https://tarnkappe.info/lesetipps-bayern-it-sicherheit-db-app-trackt-neue-eu-datenbank/" "https://catcatnya.com/@kescher/109221687024062842" "https://catcatnya.com/@kescher/109221707054861018" "https://catcatnya.com/@kescher/109221721385520640" "https://catcatnya.com/@kescher/109221750082044200" "https://brid.gy/post/twitter/seirdy/1536747178877673475" "https://markesler.com/blog/website-design/" "https://catcatnya.com/@kescher/108601418196537980" "https://chaos.social/@n0toose/109035270210401105" "https://nicfab.it/en/posts/aware-digital-communication-respecting-privacy-and-the-apps-or-services-you-choose/" "https://haxf4rall.com/2022/09/23/a-collection-of-articles-about-hardening-linux/" "https://mastodon.randomroad.social/@dctrud/108680634691924661" "https://brid.gy/post/twitter/seirdy/1535891978969174016" "https://mastodon.technology/@codeberg/108403449317373462" "https://harveyr.net/posts/14kb/" "https://brid.gy/comment/mastodon/@Seirdy@pleroma.envs.net/ANUjukccjwEmivz3ia/ANUmmjSDUviUeCz42S" "https://forum.fedeproxy.eu/t/keep-platform-open-article/161" "https://forum.forgefriends.org/t/keep-platform-open-article/161" "https://collapsitarian.io/notice/AP5QssaOBF4HLmDf8q") -}}

View file

@ -1,13 +1,6 @@
{{- $wbmLinks := (slice "https://si3t.ch/log/2021-04-18-entetes-floc.html" "https://xmpp.org/2021/02/newsletter-02-feburary/" "https://gurlic.com/technology/post/393626430212145157" "https://gurlic.com/technology/post/343249858599059461" "https://www.librepunk.club/@penryn/108411423190214816" "https://benign.town/@josias/108457015755310198" "http://www.tuxmachines.org/node/148146" "https://i.reddit.com/r/web_design/comments/k0dmpj/an_opinionated_list_of_best_practices_for_textual/gdmxy4u/" "https://bbbhltz.space/posts/thoughts-on-tech-feb2021/" "https://jorts.horse/@alice/108477866954580532" "https://brid.gy/comment/mastodon/@Seirdy@pleroma.envs.net/AK7FeQ4h2tUCKNwlXc/AK7GtGkE7JOVgm1Cgi" "https://fosstodon.org/@werwolf/108529382741681838" "https://mastodon.social/@WahbAllat/108986614624476982" "https://linuxrocks.online/@friend/109029028283860044" "https://fosstodon.org/@fullstackthaumaturge/108765040526523487" "https://inhji.de/notes/an-opinionated-list-of-best-practices-for-textual-websites" "https://ravidwivedi.in/whatsapp/" "https://hackers.town/@theruran/108440680870400884" "https://hackers.town/@theruran/108440475936938471" "https://mckinley.cc/twtxt/2022-may-aug.html#2022-06-25T16:06:07-07:00" "https://tarnkappe.info/lesetipps-bayern-it-sicherheit-db-app-trackt-neue-eu-datenbank/" "https://catcatnya.com/@kescher/109221687024062842" "https://catcatnya.com/@kescher/109221707054861018" "https://catcatnya.com/@kescher/109221721385520640" "https://catcatnya.com/@kescher/109221750082044200" "https://brid.gy/post/twitter/seirdy/1536747178877673475" "https://markesler.com/blog/website-design/" "https://catcatnya.com/@kescher/108601418196537980" "https://chaos.social/@n0toose/109035270210401105" "https://nicfab.it/en/posts/aware-digital-communication-respecting-privacy-and-the-apps-or-services-you-choose/" "https://haxf4rall.com/2022/09/23/a-collection-of-articles-about-hardening-linux/" "https://mastodon.randomroad.social/@dctrud/108680634691924661" "https://brid.gy/post/twitter/seirdy/1535891978969174016" "https://mastodon.technology/@codeberg/108403449317373462" "https://harveyr.net/posts/14kb/" "https://brid.gy/comment/mastodon/@Seirdy@pleroma.envs.net/ANUjukccjwEmivz3ia/ANUmmjSDUviUeCz42S" "https://forum.fedeproxy.eu/t/keep-platform-open-article/161" "https://forum.forgefriends.org/t/keep-platform-open-article/161" "https://collapsitarian.io/notice/AP5QssaOBF4HLmDf8q") -}}
{{- $rewritesDict := dict "" "" -}}
{{- range $i, $r := (getCSV "," "/csv/rewrites.csv") -}}
{{- $rewritesDict = merge $rewritesDict (dict (index $r 0) (index $r 1)) -}}
{{- end -}}
<h3 id="webmentions" tabindex="-1">Web&#173;mentions</h3> <h3 id="webmentions" tabindex="-1">Web&#173;mentions</h3>
<p>This site supports <a href="https://indieweb.org/Webmention">Webmentions</a>, a backlink-based alternative to traditional comment forms.</p> <p>This site supports <a href="https://indieweb.org/Webmention">Webmentions</a>, a backlink-based alternative to traditional comment forms.</p>
<details><summary>Send a Webmention</summary>{{ partial "webmention-form.html" . }}</details> <details><summary>Send a Webmention</summary>{{ partial "webmentions/webmention-form.html" . }}</details>
{{- /* Fetch all webmentions with bearer token */ -}}
{{- $allMentions := (index .Site.Data "webmentions").items -}}
{{- /* Filter webmentions to just the ones for the current targets */ -}} {{- /* Filter webmentions to just the ones for the current targets */ -}}
{{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" -}} {{- $canonicalRelPermalink := .RelPermalink | replaceRE "^/~seirdy/" "/" -}}
{{- $target := printf "%s%s" .Site.Params.CanonicalBaseURL $canonicalRelPermalink -}} {{- $target := printf "%s%s" .Site.Params.CanonicalBaseURL $canonicalRelPermalink -}}
@ -19,7 +12,7 @@
{{- end -}} {{- end -}}
{{- /* We can't just use a simple "where" function because we need to ignore URL anchors/query-params when making a comparison: https://discourse.gohugo.io/t/add-like-comparison-operator-to-the-where-function/42013/4 */ -}} {{- /* We can't just use a simple "where" function because we need to ignore URL anchors/query-params when making a comparison: https://discourse.gohugo.io/t/add-like-comparison-operator-to-the-where-function/42013/4 */ -}}
{{- $webmentions := slice -}} {{- $webmentions := slice -}}
{{- range $allMentions -}} {{- range partialCached "webmentions/all-webmentions.html" . -}}
{{- if in $targets .target -}} {{- if in $targets .target -}}
{{ $webmentions = $webmentions | append . }} {{ $webmentions = $webmentions | append . }}
{{- else -}} {{- else -}}
@ -54,10 +47,10 @@
{{- $title = $webmention.title | strings.TrimSuffix "…" | truncate 128 -}} {{- $title = $webmention.title | strings.TrimSuffix "…" | truncate 128 -}}
{{- end -}} {{- end -}}
{{- $src := $webmention.source -}} {{- $src := $webmention.source -}}
{{- with index $rewritesDict $src -}} {{- with index (partialCached "webmentions/rewrites.html" .) $src -}}
{{- $src = . -}} {{- $src = . -}}
{{- end -}} {{- end -}}
{{- if in $wbmLinks $src -}} {{- if in (partialCached "webmentions/wbm-links.html" .) $src -}}
{{- $src = printf "https://web.archive.org/web/0/%s" $src -}} {{- $src = printf "https://web.archive.org/web/0/%s" $src -}}
{{- end -}} {{- end -}}
{{ if (eq $webmention.type "like") -}} {{ if (eq $webmention.type "like") -}}