print: fix links of subsections #340

This commit is contained in:
Sören Weber 2022-10-07 22:02:48 +02:00
parent 4a816885a7
commit 7c5586abab
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D

View file

@ -94,7 +94,10 @@
{{- $currentNode := .currentnode }}
{{- 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) }}
{{- $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)) }}
{{- $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")) }}