mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +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 }}
|
||||
<title>{{ .Scratch.Get "title" }} {{ default "::" .Site.Params.titleSeparator }} {{ .Site.Title }}</title>
|
||||
|
||||
{{- partial "favicon.html" . }}
|
||||
{{- partialCached "favicon.html" . }}
|
||||
{{- partial "stylesheet.html" . }}
|
||||
<style>
|
||||
p, li, ul {
|
||||
|
|
|
@ -9,7 +9,8 @@
|
|||
{{- else if $page.IsHome }}
|
||||
{{- $archetype = "deprecated-home" }}
|
||||
{{- 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" }}
|
||||
{{- end }}
|
||||
{{- 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 }}
|
||||
|
||||
{{- partial "favicon.html" . }}
|
||||
{{- partialCached "favicon.html" . }}
|
||||
{{- partial "stylesheet.html" . }}
|
||||
{{- partial "custom-header.html" . }}
|
||||
</head>
|
||||
|
|
|
@ -3,8 +3,10 @@
|
|||
{{- $parameter := .parameter }}
|
||||
{{- $format := partial "output-format.hugo" $page }}
|
||||
{{- $suffix := partial "output-suffix.hugo" $page }}
|
||||
{{- if or (not $format) (not (fileExists (printf "/layouts/partials/%s.%s.%s" $base $format $suffix))) }}
|
||||
{{- if (fileExists (printf "/layouts/partials/%s.%s" $base $suffix)) }}
|
||||
{{- $f := printf "/layouts/partials/%s.%s.%s" $base $format $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 }}
|
||||
{{- end }}
|
||||
{{- else }}
|
||||
|
|
|
@ -10,8 +10,8 @@
|
|||
{{- $quotedcontentlangs := slice }}
|
||||
{{- $missingcontentlangs := slice }}
|
||||
{{- range $contentlangs }}
|
||||
{{- $file := (printf "js/lunr.%s.min.js" .) }}
|
||||
{{- if fileExists (printf "/static/%s" $file) }}
|
||||
{{- $f := printf "/static/js/lunr.%s.min.js" . }}
|
||||
{{- if partialCached "fileExists.hugo" $f $f }}
|
||||
{{- $quotedcontentlangs = $quotedcontentlangs | append (printf "'%s'" .) }}
|
||||
{{- else }}
|
||||
{{- $missingcontentlangs = $missingcontentlangs | append . }}
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
<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/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">
|
||||
{{- end }}
|
||||
<script src="{{"js/variant.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
|
||||
|
|
Loading…
Reference in a new issue