theme: fix race condition for nested articles #308

This commit is contained in:
Sören Weber 2022-07-11 23:52:59 +02:00
parent b8a49da2f5
commit 7f3fbe1753
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
6 changed files with 21 additions and 24 deletions

View file

@ -7,7 +7,7 @@
<script src="{{"js/clipboard.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}" defer></script>
<script src="{{"js/perfect-scrollbar.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}" defer></script>
<script src="{{"js/featherlight.min.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}" defer></script>
{{- $wantsMathJax := .Scratch.Get (printf "%sHasMathJax" ((partial "output-format.html" .) | lower)) }}
{{- $wantsMathJax := or (.Page.Store.Get "hasMathJax") (and (.Page.Store.Get (printf "%sIsNested" ((partial "output-format.html" .Page) | lower))) (.Page.Store.Get "nestedHasMathJax")) }}
{{- if $wantsMathJax }}
{{- if isset .Params "mathjaxinitialize" }}
{{- $.Scratch.Set "mathJaxInitialize" .Params.mathJaxInitialize }}
@ -48,7 +48,7 @@
<script id="MathJax-script" async src="{{"js/mathjax/tex-mml-chtml.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}"></script>
{{- end }}
{{- end }}
{{- $wantsMermaid := .Scratch.Get (printf "%sHasMermaid" ((partial "output-format.html" .) | lower)) }}
{{- $wantsMermaid := or (.Page.Store.Get "hasMermaid") (and (.Page.Store.Get (printf "%sIsNested" ((partial "output-format.html" .Page) | lower))) (.Page.Store.Get "nestedHasMermaid")) }}
{{- if $wantsMermaid }}
<script src="{{"js/jquery.svg.pan.zoom.js" | relURL}}{{ if not .Site.Params.disableAssetsBusting }}?{{ now.Unix }}{{ end }}" defer></script>
{{- if isset .Params "custommermaidurl" }}
@ -78,7 +78,7 @@
useMermaid( JSON.parse({{ $.Scratch.Get "mermaidInitialize" }}) );
</script>
{{- end }}
{{- $wantsSwagger := .Scratch.Get (printf "%sHasSwagger" ((partial "output-format.html" .) | lower)) }}
{{- $wantsSwagger := or (.Page.Store.Get "hasSwagger") (and (.Page.Store.Get (printf "%sIsNested" ((partial "output-format.html" .Page) | lower))) (.Page.Store.Get "nestedHasSwagger")) }}
{{- if $wantsSwagger }}
{{- if isset .Params "customswaggerurl" }}
<script src="{{ .Params.customSwaggerURL }}" defer></script>

View file

@ -94,10 +94,8 @@
{{- $page := . }}
{{- $content := partial "content.html" $page }}
{{- partial "output-partial.html" (dict "base" "output-article" "page" $page "parameter" (dict "page" $page "content" $content)) }}
{{- range $page.OutputFormats }}
{{- $currentNode.Scratch.Set (printf "%sHasMathJax" (.Name | lower)) (or ($currentNode.Scratch.Get (printf "%sHasMathJax" (.Name | lower))) ($page.Scratch.Get (printf "%sHasMathJax" (.Name | lower)))) }}
{{- $currentNode.Scratch.Set (printf "%sHasMermaid" (.Name | lower)) (or ($currentNode.Scratch.Get (printf "%sHasMermaid" (.Name | lower))) ($page.Scratch.Get (printf "%sHasMermaid" (.Name | lower)))) }}
{{- $currentNode.Scratch.Set (printf "%sHasSwagger" (.Name | lower)) (or ($currentNode.Scratch.Get (printf "%sHasSwagger" (.Name | lower))) ($page.Scratch.Get (printf "%sHasSwagger" (.Name | lower)))) }}
{{- end }}
{{- $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")) }}
{{- end }}
{{- end }}

View file

@ -5,10 +5,18 @@
{{- $currentNode.Scratch.Delete "relearnIsHiddenNode" }}{{/* the node itself is flagged as hidden */}}
{{- $currentNode.Scratch.Delete "relearnIsHiddenStem" }}{{/* the node or one of its parents is flagged as hidden */}}
{{- $currentNode.Scratch.Delete "relearnIsHiddenFrom" }}{{/* the node is hidden from the current page */}}
{{- range $currentNode.OutputFormats }}
{{- $currentNode.Scratch.Delete (printf "%sHasMathJax" (.Name | lower)) }}
{{- $currentNode.Scratch.Delete (printf "%sHasMermaid" (.Name | lower)) }}
{{- $currentNode.Scratch.Delete (printf "%sHasSwagger" (.Name | lower)) }}
{{- $currentNode.Scratch.Delete (printf "%sWantsMathJax" ((partial "output-format.html" $currentNode) | lower)) }}
{{- $wantsMathjax := or (and (ne $currentNode.Params.disableMathjax nil) (not $currentNode.Params.disableMathjax)) (and (ne .Site.Params.disableMathjax nil) (not .Site.Params.disableMathjax)) }}
{{- if $wantsMathjax }}
{{- $currentNode.Store.Set "hasMathJax" true }}
{{- end }}
{{- $wantsMermaid := or (and (ne $currentNode.Params.disableMermaid nil) (not $currentNode.Params.disableMermaid)) (and (ne .Site.Params.disableMermaid nil) (not .Site.Params.disableMermaid)) }}
{{- if $wantsMermaid }}
{{- $currentNode.Store.Set "hasMermaid" true }}
{{- end }}
{{- $wantsSwagger := or (and (ne $currentNode.Params.disableSwagger nil) (not $currentNode.Params.disableSwagger)) (and (ne .Site.Params.disableSwagger nil) (not .Site.Params.disableSwagger)) }}
{{- if $wantsSwagger }}
{{- $currentNode.Store.Set "hasSwagger" true }}
{{- end }}
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false "defaultOrdersectionsby" .Site.Params.ordersectionsby }}
{{- define "relearn-structure" }}

View file

@ -5,8 +5,5 @@
<span class="math align-{{ $align }}">
{{- $content | safeHTML -}}
</span>
{{- $page := .Page }}
{{- range $page.OutputFormats }}
{{- $page.Scratch.Set (printf "%sHasMathJax" (.Name | lower)) true }}
{{- end }}
{{- .Page.Store.Set "hasMathJax" true }}
{{- end }}

View file

@ -5,8 +5,5 @@
<div class="mermaid" align="{{ $align }}">
{{- $content | safeHTML -}}
</div>
{{- $page := .Page }}
{{- range $page.OutputFormats }}
{{- $page.Scratch.Set (printf "%sHasMermaid" (.Name | lower)) true }}
{{- end }}
{{- .Page.Store.Set "hasMermaid" true }}
{{- end }}

View file

@ -24,8 +24,5 @@
spec-url="{{ $src }}"
sort-tags="true"
></rapi-doc>
{{- $page := .Page }}
{{- range $page.OutputFormats }}
{{- $page.Scratch.Set (printf "%sHasSwagger" (.Name | lower)) true }}
{{- end }}
{{- .Page.Store.Set "hasSwagger" true }}
{{- end }}