From 5971d3d5fa1fb0667ae9b8db012bc759df238a32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Weber?= Date: Sun, 13 Nov 2022 16:36:40 +0100 Subject: [PATCH] theme: cache nested articles #380 --- layouts/partials/nested-article.hugo | 6 +----- layouts/partials/nested-content.hugo | 7 +++++++ layouts/partials/shortcodes/expand.html | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 layouts/partials/nested-content.hugo diff --git a/layouts/partials/nested-article.hugo b/layouts/partials/nested-article.hugo index a29fa28d19..c52315ddbb 100644 --- a/layouts/partials/nested-article.hugo +++ b/layouts/partials/nested-article.hugo @@ -93,11 +93,7 @@ {{- $outputFormat := .outputFormat }} {{- with .sect }} {{- $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 */}} - {{- $link_prefix := strings.TrimRight "/" .Page.RelPermalink }} - {{- $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 }} - {{- partial "output-partial.hugo" (dict "base" "article" "page" $page "parameter" (dict "page" $page "content" $content "outputFormat" $outputFormat) "outputFormat" $outputFormat) }} + {{- partialCached "nested-content.hugo" (dict "page" $page "outputFormat" $outputFormat) $page.RelPermalink "outputFormat" $outputFormat }} {{- $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 "nestedHasSwagger" (or ($currentNode.Page.Store.Get "nestedHasSwagger") (.Page.Store.Get "hasSwagger")) }} diff --git a/layouts/partials/nested-content.hugo b/layouts/partials/nested-content.hugo new file mode 100644 index 0000000000..824e52386b --- /dev/null +++ b/layouts/partials/nested-content.hugo @@ -0,0 +1,7 @@ +{{- $page := .page }} +{{- $outputFormat := .outputFormat }} +{{- $c:=""}}{{/* 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 }} +{{- $content := partial "output-partial.hugo" (dict "base" "content" "page" $page "parameter" $page "outputFormat" $outputFormat) }} +{{- $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 "outputFormat" $outputFormat) "outputFormat" $outputFormat) }} \ No newline at end of file diff --git a/layouts/partials/shortcodes/expand.html b/layouts/partials/shortcodes/expand.html index cf0166e7f4..0143632a6f 100644 --- a/layouts/partials/shortcodes/expand.html +++ b/layouts/partials/shortcodes/expand.html @@ -10,7 +10,7 @@
- {{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}{{ "" -}} + {{- $c:=""}}{{/* things are getting complicated when search tries to open the expand box while jquery sets the display CSS on the element */}}