mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
theme: cache calls to fileExists #380
This commit is contained in:
parent
f23d4163d8
commit
82a8b2f8c6
7 changed files with 13 additions and 8 deletions
|
@ -11,7 +11,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<title>{{ .Scratch.Get "title" }} {{ default "::" .Site.Params.titleSeparator }} {{ .Site.Title }}</title>
|
<title>{{ .Scratch.Get "title" }} {{ default "::" .Site.Params.titleSeparator }} {{ .Site.Title }}</title>
|
||||||
|
|
||||||
{{- partial "favicon.html" . }}
|
{{- partialCached "favicon.html" . }}
|
||||||
{{- partial "stylesheet.html" . }}
|
{{- partial "stylesheet.html" . }}
|
||||||
<style>
|
<style>
|
||||||
p, li, ul {
|
p, li, ul {
|
||||||
|
|
|
@ -9,7 +9,8 @@
|
||||||
{{- else if $page.IsHome }}
|
{{- else if $page.IsHome }}
|
||||||
{{- $archetype = "deprecated-home" }}
|
{{- $archetype = "deprecated-home" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if not (fileExists (printf "/layouts/partials/archetypes/%s" $archetype)) }}
|
{{- $f := printf "/layouts/partials/archetypes/%s" $archetype }}
|
||||||
|
{{- if not (partialCached "fileExists.hugo" $f $f) }}
|
||||||
{{- $archetype = "default" }}
|
{{- $archetype = "default" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" (printf "archetypes/%s/%s" $archetype $hook) "page" $page "parameter" $parameter) }}
|
{{- partial "output-partial.hugo" (dict "base" (printf "archetypes/%s/%s" $archetype $hook) "page" $page "parameter" $parameter) }}
|
1
layouts/partials/fileExists.hugo
Normal file
1
layouts/partials/fileExists.hugo
Normal file
|
@ -0,0 +1 @@
|
||||||
|
{{- return fileExists . }}
|
|
@ -29,7 +29,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- partial "favicon.html" . }}
|
{{- partialCached "favicon.html" . }}
|
||||||
{{- partial "stylesheet.html" . }}
|
{{- partial "stylesheet.html" . }}
|
||||||
{{- partial "custom-header.html" . }}
|
{{- partial "custom-header.html" . }}
|
||||||
</head>
|
</head>
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
{{- $parameter := .parameter }}
|
{{- $parameter := .parameter }}
|
||||||
{{- $format := partial "output-format.hugo" $page }}
|
{{- $format := partial "output-format.hugo" $page }}
|
||||||
{{- $suffix := partial "output-suffix.hugo" $page }}
|
{{- $suffix := partial "output-suffix.hugo" $page }}
|
||||||
{{- if or (not $format) (not (fileExists (printf "/layouts/partials/%s.%s.%s" $base $format $suffix))) }}
|
{{- $f := printf "/layouts/partials/%s.%s.%s" $base $format $suffix }}
|
||||||
{{- if (fileExists (printf "/layouts/partials/%s.%s" $base $suffix)) }}
|
{{- if or (not $format) (not (partialCached "fileExists.hugo" $f $f)) }}
|
||||||
|
{{- $f = printf "/layouts/partials/%s.%s" $base $suffix }}
|
||||||
|
{{- if partialCached "fileExists.hugo" $f $f }}
|
||||||
{{- partial (printf "%s.%s" $base $suffix) $parameter }}
|
{{- partial (printf "%s.%s" $base $suffix) $parameter }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
|
|
|
@ -10,8 +10,8 @@
|
||||||
{{- $quotedcontentlangs := slice }}
|
{{- $quotedcontentlangs := slice }}
|
||||||
{{- $missingcontentlangs := slice }}
|
{{- $missingcontentlangs := slice }}
|
||||||
{{- range $contentlangs }}
|
{{- range $contentlangs }}
|
||||||
{{- $file := (printf "js/lunr.%s.min.js" .) }}
|
{{- $f := printf "/static/js/lunr.%s.min.js" . }}
|
||||||
{{- if fileExists (printf "/static/%s" $file) }}
|
{{- if partialCached "fileExists.hugo" $f $f }}
|
||||||
{{- $quotedcontentlangs = $quotedcontentlangs | append (printf "'%s'" .) }}
|
{{- $quotedcontentlangs = $quotedcontentlangs | append (printf "'%s'" .) }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- $missingcontentlangs = $missingcontentlangs | append . }}
|
{{- $missingcontentlangs = $missingcontentlangs | append . }}
|
||||||
|
|
|
@ -14,7 +14,8 @@
|
||||||
<link href="{{"css/ie.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
<link href="{{"css/ie.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
||||||
<link href="{{"css/variant.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
<link href="{{"css/variant.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
||||||
<link href="{{"css/print.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" media="print">
|
<link href="{{"css/print.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" media="print">
|
||||||
{{- if (fileExists (printf "/static/css/format-%s.css" (partial "output-format.hugo" .))) }}
|
{{- $f := printf "/static/css/format-%s.css" (partial "output-format.hugo" .) }}
|
||||||
|
{{- if partialCached "fileExists.hugo" $f $f }}
|
||||||
<link href="{{(printf "css/format-%s.css" (partial "output-format.hugo" .)) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
<link href="{{(printf "css/format-%s.css" (partial "output-format.hugo" .)) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
||||||
{{- end }}
|
{{- end }}
|
||||||
<script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
|
<script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
|
||||||
|
|
Loading…
Reference in a new issue