From df0455d16fcec4da0556e3e86992bd1f48a408fc Mon Sep 17 00:00:00 2001 From: David Karlsson <35727626+dvdksn@users.noreply.github.com> Date: Mon, 4 Mar 2024 12:49:44 +0100 Subject: [PATCH] hugo: improve build performance use cached partials for repeat templates and icons Signed-off-by: David Karlsson <35727626+dvdksn@users.noreply.github.com> --- content/scout/integrations/registry/acr.md | 4 ++- .../_default/_markup/render-codeblock.html | 4 +-- layouts/_default/_markup/render-image.html | 2 +- layouts/_default/_markup/render-link.html | 2 +- layouts/_default/cli.html | 26 +++++++++---------- layouts/index.html | 2 +- layouts/partials/components/accordion.html | 4 +-- layouts/partials/github-links.html | 8 +++--- layouts/partials/head.html | 4 +-- layouts/partials/header.html | 6 ++--- layouts/partials/sidebar.html | 4 +-- layouts/partials/tooltip.html | 2 +- 12 files changed, 35 insertions(+), 33 deletions(-) diff --git a/content/scout/integrations/registry/acr.md b/content/scout/integrations/registry/acr.md index adb24c6bf9..13e464d936 100644 --- a/content/scout/integrations/registry/acr.md +++ b/content/scout/integrations/registry/acr.md @@ -54,12 +54,14 @@ the Azure resources. {{< accordion title="JSON template" >}} {{< acr-template.inline >}} -{{ $data := data.GetJSON "https://prod-scout-integration-templates.s3.amazonaws.com/latest/acr_token_template.json" }} +{{ with resources.GetRemote "https://prod-scout-integration-templates.s3.amazonaws.com/latest/acr_token_template.json" }} +{{ $data := .Content | transform.Unmarshal }} ```json {{ transform.Remarshal "json" $data }} ``` +{{ end }} {{< /acr-template.inline >}} {{< /accordion >}} diff --git a/layouts/_default/_markup/render-codeblock.html b/layouts/_default/_markup/render-codeblock.html index 09dc6afcf4..59e59f45f9 100644 --- a/layouts/_default/_markup/render-codeblock.html +++ b/layouts/_default/_markup/render-codeblock.html @@ -7,8 +7,8 @@ copying = true; setTimeout(() => copying = false, 2000);" > - {{ partial "icon" "content_copy" }} - {{ partial "icon" "check_circle" }} + {{ partialCached "icon" "content_copy" "content_copy" }} + {{ partialCached "icon" "check_circle" "check_circle" }} {{ $result := transform.HighlightCodeBlock . }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" "Kubernetes") }} + {{ partialCached "components/badge.html" (dict "color" "blue" "content" "Kubernetes") "k8s" }} This command works with the Kubernetes orchestrator.
{{ end }} {{ with $data.swarm }}- {{ partial "components/badge.html" (dict "color" "blue" "content" "Swarm") }} + {{ partialCached "components/badge.html" (dict "color" "blue" "content" "Swarm") "swarm" }} This command works with the Swarm orchestrator.
{{ end }} {{ with $data.long }} {{ $heading := dict "level" 2 "text" "Description" }} - {{ partial "heading.html" $heading }} + {{ partialCached "heading.html" $heading "cli-description" }} {{ $subHeadings := (strings.FindRE `(?m:#{3,4} .*)` .) }} {{ $.Scratch.Add "headings" $heading }} {{ range $subHeadings }} @@ -97,7 +97,7 @@ {{ $opts := where . "hidden" false }} {{ with $opts }} {{ $heading := dict "level" 2 "text" "Options" }} - {{ partial "heading.html" $heading }} + {{ partialCached "heading.html" $heading "cli-options" }} {{ $.Scratch.Add "headings" $heading }}
{{ with .min_api_version }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) }}
+ {{ partialCached "components/badge.html" (dict "color" "blue" "content" (printf "API %s+" .)) "api" . }}
{{ end }}
{{ with .deprecated }}
- {{ partial "components/badge.html" (dict "color" "red" "content" "Deprecated") }}
+ {{ partialCached "components/badge.html" (dict "color" "red" "content" "Deprecated") "deprecated" }}
{{ end }}
{{ with .experimental }}
- {{ partial "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") }}
+ {{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (daemon)") "exp" }}
{{ end }}
{{ with .experimentalcli }}
- {{ partial "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") }}
+ {{ partialCached "components/badge.html" (dict "color" "amber" "content" "experimental (CLI)") "exp-cli" }}
{{ end }}
{{ with .kubernetes }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" "Kubernetes") }}
+ {{ partialCached "components/badge.html" (dict "color" "blue" "content" "Kubernetes") "k8s" }}
{{ end }}
{{ with .swarm }}
- {{ partial "components/badge.html" (dict "color" "blue" "content" "Swarm") }}
+ {{ partialCached "components/badge.html" (dict "color" "blue" "content" "Swarm") "swarm" }}
{{ end }}
{{ if .description }}
{{/* replace newlines in long desc with break tags */}}
@@ -159,7 +159,7 @@
{{ end }}
{{ with $data.examples }}
{{ $heading := dict "level" 2 "text" "Examples" }}
- {{ partial "heading.html" $heading }}
+ {{ partialCached "heading.html" $heading "cli-examples" }}
{{ $subHeadings := (strings.FindRE `(?m:#{3,4} .*)` .) }}
{{ $.Scratch.Add "headings" $heading }}
{{ range $subHeadings }}
@@ -171,7 +171,7 @@
{{ end }}
{{ if eq .Kind "section" }}
{{ $heading := dict "level" 2 "text" "Subcommands" }}
- {{ partial "heading.html" $heading }}
+ {{ partialCached "heading.html" $heading "cli-subcommands" }}
{{ $.Scratch.Add "headings" $heading }}
|