mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2025-01-18 19:00:24 +00:00
theme: reduce calls to output-format.hugo III #380
This commit is contained in:
parent
dbb37a29a8
commit
1c251f0790
11 changed files with 52 additions and 28 deletions
|
@ -1,5 +1,6 @@
|
||||||
{{- partialCached "page-meta.hugo" . . }}
|
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
{{- partialCached "page-meta.hugo" . . }}
|
||||||
|
{{- $outputFormat := partial "output-format.hugo" . }}
|
||||||
<html lang="{{ .Page.Language | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
|
<html lang="{{ .Page.Language | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
|
||||||
<head>
|
<head>
|
||||||
{{- partial "meta.html" . }}
|
{{- partial "meta.html" . }}
|
||||||
|
@ -12,7 +13,7 @@
|
||||||
<title>{{ .Scratch.Get "title" }} {{ default "::" .Site.Params.titleSeparator }} {{ .Site.Title }}</title>
|
<title>{{ .Scratch.Get "title" }} {{ default "::" .Site.Params.titleSeparator }} {{ .Site.Title }}</title>
|
||||||
|
|
||||||
{{- partialCached "favicon.html" . }}
|
{{- partialCached "favicon.html" . }}
|
||||||
{{- partial "stylesheet.html" . }}
|
{{- partialCached "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) $outputFormat }}
|
||||||
<style>
|
<style>
|
||||||
p, li, ul {
|
p, li, ul {
|
||||||
text-align: center
|
text-align: center
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
{{- partialCached "page-meta.hugo" . . }}
|
{{- partialCached "page-meta.hugo" . . }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" "header" "page" . "parameter" .) }}
|
{{- $outputFormat := partial "output-format.hugo" . }}
|
||||||
|
{{- partial "output-partial.hugo" (dict "base" "header" "page" . "parameter" . "outputFormat" $outputFormat) }}
|
||||||
{{- if not .File }}
|
{{- if not .File }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "initial" "page" . "parameter" .)))) }}
|
{{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "initial" "page" . "parameter" . "outputFormat" $outputFormat))) "outputFormat" $outputFormat) }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" .)))) }}
|
{{- partial "output-partial.hugo" (dict "base" "body" "page" . "parameter" (dict "page" . "content" (partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" . "outputFormat" $outputFormat))) "outputFormat" $outputFormat) }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" "footer" "page" . "parameter" .) }}
|
{{- partial "output-partial.hugo" (dict "base" "footer" "page" . "parameter" . "outputFormat" $outputFormat) }}
|
|
@ -1,6 +1,10 @@
|
||||||
{{- $hook := .hook }}
|
{{- $hook := .hook }}
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $parameter := .parameter }}
|
{{- $parameter := .parameter }}
|
||||||
|
{{- $outputFormat := .outputFormat }}
|
||||||
|
{{- if not $outputFormat }}
|
||||||
|
{{- $outputFormat = partial "output-format.hugo" $page }}
|
||||||
|
{{- end }}
|
||||||
{{- $archetype := "default" }}
|
{{- $archetype := "default" }}
|
||||||
{{- if $page.Params.archetype }}
|
{{- if $page.Params.archetype }}
|
||||||
{{- $archetype = $page.Params.archetype }}
|
{{- $archetype = $page.Params.archetype }}
|
||||||
|
@ -13,4 +17,4 @@
|
||||||
{{- if not (partialCached "fileExists.hugo" $f $f) }}
|
{{- 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 "outputFormat" $outputFormat) }}
|
|
@ -1,3 +1,4 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $content := .content }}
|
{{- $content := .content }}
|
||||||
{{- partial "archetype.hugo" (dict "hook" "article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
|
{{- $outputFormat := .outputFormat }}
|
||||||
|
{{- partial "archetype.hugo" (dict "hook" "article" "page" $page "parameter" (dict "page" $page "content" $content) "outputFormat" $outputFormat) }}
|
|
@ -1,3 +1,4 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $content := .content }}
|
{{- $content := .content }}
|
||||||
{{- partial "single-article.hugo" (dict "page" $page "content" $content) }}
|
{{- $outputFormat := partial "output-format.hugo" .page }}
|
||||||
|
{{- partial "single-article.hugo" (dict "page" $page "content" $content "outputFormat" $outputFormat) }}
|
|
@ -1,3 +1,4 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $content := .content }}
|
{{- $content := .content }}
|
||||||
{{- partial "nested-article.hugo" (dict "page" $page) }}
|
{{- $outputFormat := partial "output-format.hugo" .page }}
|
||||||
|
{{- partial "nested-article.hugo" (dict "page" $page "outputFormat" $outputFormat) }}
|
|
@ -1,4 +1,5 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
|
{{- $outputFormat := partial "output-format.hugo" . }}
|
||||||
<html lang="{{ .Page.Language | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
|
<html lang="{{ .Page.Language | default "en" }}" dir="{{ T "Reading-direction" | default "ltr" }}">
|
||||||
<head>
|
<head>
|
||||||
{{- partial "meta.html" . }}
|
{{- partial "meta.html" . }}
|
||||||
|
@ -30,10 +31,10 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- partialCached "favicon.html" . }}
|
{{- partialCached "favicon.html" . }}
|
||||||
{{- partial "stylesheet.html" . }}
|
{{- partialCached "stylesheet.html" (dict "page" . "outputFormat" $outputFormat) $outputFormat }}
|
||||||
{{- partial "custom-header.html" . }}
|
{{- partial "custom-header.html" . }}
|
||||||
</head>
|
</head>
|
||||||
<body class="mobile-support {{ (partial "output-format.hugo" .) }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}" data-url="{{ .RelPermalink }}">
|
<body class="mobile-support {{ $outputFormat }}{{- if .Site.Params.disableInlineCopyToClipBoard }} disableInlineCopyToClipboard{{ end }}" data-url="{{ .RelPermalink }}">
|
||||||
<div id="body" class="default-animation">
|
<div id="body" class="default-animation">
|
||||||
<div id="sidebar-overlay"></div>
|
<div id="sidebar-overlay"></div>
|
||||||
<div id="toc-overlay"></div>
|
<div id="toc-overlay"></div>
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $page.Page.Store.Set (printf "%sIsNested" (partial "output-format.hugo" $page)) true }}
|
{{- $outputFormat := .outputFormat }}
|
||||||
|
{{- $page.Page.Store.Set (printf "%sIsNested" $outputFormat) true }}
|
||||||
{{- with $page }}
|
{{- with $page }}
|
||||||
{{- $currentNode := . }}
|
{{- $currentNode := . }}
|
||||||
{{- $isActive := .IsHome }}
|
{{- $isActive := .IsHome }}
|
||||||
|
@ -17,22 +18,22 @@
|
||||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||||
{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
|
{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
|
||||||
{{- if $isShortcut }}
|
{{- if $isShortcut }}
|
||||||
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- if $isActive }}
|
{{- if $isActive }}
|
||||||
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat }}
|
||||||
{{- if or $pages }}
|
{{- if $pages }}
|
||||||
<section>
|
<section>
|
||||||
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
|
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if eq $currentOrdersectionsby "title" }}
|
{{- if eq $currentOrdersectionsby "title" }}
|
||||||
{{- range $pages.ByTitle }}
|
{{- range $pages.ByTitle }}
|
||||||
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat "isActive" $isActive }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- range $pages.ByWeight }}
|
{{- range $pages.ByWeight }}
|
||||||
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat "isActive" $isActive }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $isActive }}
|
{{- if $isActive }}
|
||||||
|
@ -44,6 +45,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- define "section-tree-print" }}
|
{{- define "section-tree-print" }}
|
||||||
{{- $currentNode := .currentnode }}
|
{{- $currentNode := .currentnode }}
|
||||||
|
{{- $outputFormat := .outputFormat }}
|
||||||
{{- $isActive := .isActive }}
|
{{- $isActive := .isActive }}
|
||||||
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}
|
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}
|
||||||
{{- with .sect }}
|
{{- with .sect }}
|
||||||
|
@ -63,7 +65,7 @@
|
||||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||||
{{- $currentOrdersectionsby := .Params.ordersectionsby | default $defaultOrdersectionsby }}
|
{{- $currentOrdersectionsby := .Params.ordersectionsby | default $defaultOrdersectionsby }}
|
||||||
{{- if $isActive }}
|
{{- if $isActive }}
|
||||||
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat }}
|
||||||
{{- if $pages }}
|
{{- if $pages }}
|
||||||
<section>
|
<section>
|
||||||
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
|
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
|
||||||
|
@ -71,11 +73,11 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if eq $currentOrdersectionsby "title" }}
|
{{- if eq $currentOrdersectionsby "title" }}
|
||||||
{{- range $pages.ByTitle }}
|
{{- range $pages.ByTitle }}
|
||||||
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat "isActive" $isActive }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- range $pages.ByWeight }}
|
{{- range $pages.ByWeight }}
|
||||||
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat "isActive" $isActive }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $isActive }}
|
{{- if $isActive }}
|
||||||
|
@ -88,13 +90,14 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- define "section-print" }}
|
{{- define "section-print" }}
|
||||||
{{- $currentNode := .currentnode }}
|
{{- $currentNode := .currentnode }}
|
||||||
|
{{- $outputFormat := .outputFormat }}
|
||||||
{{- with .sect }}
|
{{- with .sect }}
|
||||||
{{- $page := . }}
|
{{- $page := . }}
|
||||||
{{/* if we have a relative link in a print page, our print URL is one level to deep; so we are making it absolute to our page by prepending the page's permalink */}}
|
{{/* if we have a relative link in a print page, our print URL is one level to deep; so we are making it absolute to our page by prepending the page's permalink */}}
|
||||||
{{- $link_prefix := strings.TrimRight "/" .Page.RelPermalink }}
|
{{- $link_prefix := strings.TrimRight "/" .Page.RelPermalink }}
|
||||||
{{- $content := partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" $page) }}
|
{{- $content := partial "output-partial.hugo" (dict "base" "content" "page" . "parameter" $page "outputFormat" $outputFormat) }}
|
||||||
{{- $content = replaceRE "((?:src|href)\\s*=(?:\\s*[\"']\\s*)?)(\\.[^\"'\\s>]*|[\\w]+[^\"'\\s>:]*)([\"'\\s>])" (printf "${1}%s/${2}${3}" $link_prefix) $content }}
|
{{- $content = replaceRE "((?:src|href)\\s*=(?:\\s*[\"']\\s*)?)(\\.[^\"'\\s>]*|[\\w]+[^\"'\\s>:]*)([\"'\\s>])" (printf "${1}%s/${2}${3}" $link_prefix) $content }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
|
{{- partial "output-partial.hugo" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content "outputFormat" $outputFormat) "outputFormat" $outputFormat) }}
|
||||||
{{- $currentNode.Page.Store.Set "nestedHasMathJax" (or ($currentNode.Page.Store.Get "nestedHasMathJax") (.Page.Store.Get "hasMathJax")) }}
|
{{- $currentNode.Page.Store.Set "nestedHasMathJax" (or ($currentNode.Page.Store.Get "nestedHasMathJax") (.Page.Store.Get "hasMathJax")) }}
|
||||||
{{- $currentNode.Page.Store.Set "nestedHasMermaid" (or ($currentNode.Page.Store.Get "nestedHasMermaid") (.Page.Store.Get "hasMermaid")) }}
|
{{- $currentNode.Page.Store.Set "nestedHasMermaid" (or ($currentNode.Page.Store.Get "nestedHasMermaid") (.Page.Store.Get "hasMermaid")) }}
|
||||||
{{- $currentNode.Page.Store.Set "nestedHasSwagger" (or ($currentNode.Page.Store.Get "nestedHasSwagger") (.Page.Store.Get "hasSwagger")) }}
|
{{- $currentNode.Page.Store.Set "nestedHasSwagger" (or ($currentNode.Page.Store.Get "nestedHasSwagger") (.Page.Store.Get "hasSwagger")) }}
|
||||||
|
|
|
@ -1,7 +1,10 @@
|
||||||
{{- $base := .base }}
|
{{- $base := .base }}
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $parameter := .parameter }}
|
{{- $parameter := .parameter }}
|
||||||
{{- $outputFormat := partial "output-format.hugo" $page }}
|
{{- $outputFormat := .outputFormat }}
|
||||||
|
{{- if not $outputFormat }}
|
||||||
|
{{- $outputFormat = partial "output-format.hugo" $page }}
|
||||||
|
{{- end }}
|
||||||
{{- $suffix := partialCached "output-suffix.hugo" $page $page $outputFormat }}
|
{{- $suffix := partialCached "output-suffix.hugo" $page $page $outputFormat }}
|
||||||
{{- $f := printf "/layouts/partials/%s.%s.%s" $base $outputFormat $suffix }}
|
{{- $f := printf "/layouts/partials/%s.%s.%s" $base $outputFormat $suffix }}
|
||||||
{{- if or (not $outputFormat) (not (partialCached "fileExists.hugo" $f $f)) }}
|
{{- if or (not $outputFormat) (not (partialCached "fileExists.hugo" $f $f)) }}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $content := .content }}
|
{{- $content := .content }}
|
||||||
{{- $page.Page.Store.Set (printf "%sIsNested" (partial "output-format.hugo" $page)) false }}
|
{{- $outputFormat := .outputFormat }}
|
||||||
{{- partial "output-partial.hugo" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
|
{{- $page.Page.Store.Set (printf "%sIsNested" $outputFormat) false }}
|
||||||
|
{{- partial "output-partial.hugo" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content "outputFormat" $outputFormat) "outputFormat" $outputFormat) }}
|
|
@ -1,3 +1,10 @@
|
||||||
|
{{- $page := .page }}
|
||||||
|
{{- $outputFormat := .outputFormat }}
|
||||||
|
{{- if not $page }}
|
||||||
|
{{- $page = . }}
|
||||||
|
{{- $outputFormat = partial "output-format.hugo" $page }}
|
||||||
|
{{- end }}
|
||||||
|
{{- with $page }}
|
||||||
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
|
{{- $assetBusting := not .Site.Params.disableAssetsBusting }}
|
||||||
{{ "<!-- https://github.com/filamentgroup/loadCSS/blob/master/README.md#how-to-use -->" | safeHTML }}
|
{{ "<!-- https://github.com/filamentgroup/loadCSS/blob/master/README.md#how-to-use -->" | safeHTML }}
|
||||||
<link href="{{"css/fontawesome-all.min.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="{{"css/fontawesome-all.min.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet"></noscript>
|
<link href="{{"css/fontawesome-all.min.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet" media="print" onload="this.media='all';this.onload=null;"><noscript><link href="{{"css/fontawesome-all.min.css" | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet"></noscript>
|
||||||
|
@ -14,7 +21,6 @@
|
||||||
<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">
|
||||||
{{- $outputFormat := partial "output-format.hugo" . }}
|
|
||||||
{{- $f := printf "/static/css/format-%s.css" $outputFormat }}
|
{{- $f := printf "/static/css/format-%s.css" $outputFormat }}
|
||||||
{{- if partialCached "fileExists.hugo" $f $f }}
|
{{- if partialCached "fileExists.hugo" $f $f }}
|
||||||
<link href="{{(printf "css/format-%s.css" $outputFormat) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
<link href="{{(printf "css/format-%s.css" $outputFormat) | relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" rel="stylesheet">
|
||||||
|
@ -44,4 +50,5 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
window.variants && variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] );
|
window.variants && variants.init( [ {{ delimit $quotedthemevariants ", " | safeJS }} ] );
|
||||||
</script>
|
</script>
|
||||||
<script src="{{"js/jquery.min.js"| relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
|
<script src="{{"js/jquery.min.js"| relURL}}{{ if $assetBusting }}?{{ now.Unix }}{{ end }}" defer></script>
|
||||||
|
{{- end }}
|
Loading…
Reference in a new issue