Add caching to some partials that don't change much

This commit is contained in:
BBaoVanC 2021-10-11 09:52:24 -05:00
parent 9ff5314bc0
commit 03834fb1ba
Signed by: bbaovanc
GPG Key ID: 18089E4E3CCF1D3A
7 changed files with 26 additions and 25 deletions

View File

@ -2,7 +2,7 @@
{{ .Text | safeHTML }}
<a href="#{{ .Anchor | safeURL }}">
<span class="section-header-link">
{{ partial "icon.html" "link" }}
{{ partialCached "icon.html" "link" "link" }}
</span>
</a>
</h{{ .Level }}>

View File

@ -1,20 +1,11 @@
{{ partial "credit.html" }}
{{ partialCached "credit.html" . }}
<!DOCTYPE html>
<html lang="en">
{{- partial "head.html" . -}}
<body>
<div class="top">
<h2 class="header">
<a href="{{ "/" | relURL }}">{{ .Site.Title | markdownify }}</a>
</h2>
<nav id="navbar">
<a class="navbar-item" href="{{ "/" | relURL }}">Home</a>
{{ range .Site.Menus.main }}
<a class="navbar-item" href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</nav>
{{ partialCached "top.html" . }}
</div>
<div class="content">

View File

@ -1,23 +1,23 @@
{{ define "main" }}
{{ if or (eq .Kind "term") (eq .Kind "taxonomy") }}
<h1>
{{ partial "icon.html" "filter" }}
{{ partialCached "icon.html" "filter" "filter" }}
Filtering for "{{ .Title }}"
{{ if eq .Kind "term" }}
<span class="rss-link">
{{ with .OutputFormats.Get "rss" }}
<a href="{{ .Permalink }}">{{ partial "icon.html" "rss" }}</a>
<a href="{{ .Permalink }}">{{ partialCached "icon.html" "rss" "rss" }}</a>
{{ end }}
</span>
{{ end }}
</h1>
{{ else }}
<h1>
{{ with .Params.icon }}{{ partial "icon.html" . }}{{ end }}
{{ with .Params.icon }}{{ partialCached "icon.html" . . }}{{ end }}
{{ .Title | markdownify }}
<span class="rss-link">
{{ with .OutputFormats.Get "rss" }}
<a href="{{ .Permalink }}">{{ partial "icon.html" "rss" }}</a>
<a href="{{ .Permalink }}">{{ partialCached "icon.html" "rss" "rss" }}</a>
{{ end }}
</span>
</h1>

View File

@ -2,7 +2,7 @@
<div class="post-title">
<h1>
{{ .Title | markdownify }}
{{ if .Draft }}{{ partial "icon.html" "edit" }}{{ end }}
{{ if .Draft }}{{ partialCached "icon.html" "edit" "edit" }}{{ end }}
</h1>
</div>

View File

@ -1,8 +1,8 @@
<div class="post">
<h2 class="post-title">
{{ with .Parent.Params.icon }}{{ partial "icon.html" . }}{{ end }}
{{ with .Parent.Params.icon }}{{ partialCached "icon.html" . . }}{{ end }}
<a href="{{ .Permalink }}">{{ .Title | markdownify }}</a>
{{ if .Draft }}{{ partial "icon.html" "edit" }}{{ end }}
{{ if .Draft }}{{ partialCached "icon.html" "edit" "edit" }}{{ end }}
</h2>
{{ partial "post-metadata.html" . }}

View File

@ -2,7 +2,7 @@
<div class="post-metadata">
{{ if .Date }}
<span class="post-meta-item">
{{ partial "icon.html" "calendar" }}
{{ partialCached "icon.html" "calendar" "calendar" }}
<time datetime="{{ .Date.Format "January 2, 2006" }}" pubdate>
{{ .Date.Format "January 2, 2006" }}
</time>
@ -11,7 +11,7 @@
{{ if not .Site.Params.repoURL }}
{{ if ne .Lastmod .Date }}
<span class="post-meta-item">
{{ partial "icon.html" "edit-2" }}
{{ partialCached "icon.html" "edit-2" "edit-2" }}
<time datetime="{{ .Lastmod.Format "2006-01-02" }}" pubdate>
{{ .Lastmod.Format "January 2, 2006" }}
</time>
@ -22,14 +22,14 @@
{{ if .Site.Params.wordcount }}
<span class="post-meta-item">
{{ partial "icon.html" "type" }}
{{ partialCached "icon.html" "type" "type" }}
{{ .WordCount }} words
</span>
{{ end }}
{{ if .Site.Params.readingtime }}
<span class="post-meta-item">
{{ partial "icon.html" "clock" }}
{{ partialCached "icon.html" "clock" "clock" }}
{{ .ReadingTime }} {{ if gt .ReadingTime 1 }} mins {{ else }} min {{ end }}
</span>
{{ end }}
@ -37,7 +37,7 @@
{{ if .Site.Params.repoURL }}
{{ with .GitInfo }}
<span class="post-meta-item">
{{ partial "icon.html" "git-commit" }}
{{ partialCached "icon.html" "git-commit" "git-commit" }}
<a href="{{ (printf "%s/commit/%s" $.Site.Params.repoURL .Hash) | absURL }}">
<code>{{ .AbbreviatedHash }}</code>
</a>
@ -48,7 +48,7 @@
<div class="tags">
{{ range (.GetTerms "tags") }}
<span class="post-meta-item">
{{ partial "icon.html" "tag" }}
{{ partialCached "icon.html" "tag" "tag" }}
<a href="{{ .Permalink }}">{{ .LinkTitle }}</a>
</span>
{{ end }}

10
layouts/partials/top.html Normal file
View File

@ -0,0 +1,10 @@
<h2 class="header">
<a href="{{ "/" | relURL }}">{{ .Site.Title | markdownify }}</a>
</h2>
<nav id="navbar">
<a class="navbar-item" href="{{ "/" | relURL }}">Home</a>
{{ range .Site.Menus.main }}
<a class="navbar-item" href="{{ .URL }}">{{ .Name }}</a>
{{ end }}
</nav>