mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 15:57:57 +00:00
106 lines
No EOL
4.7 KiB
Text
106 lines
No EOL
4.7 KiB
Text
{{- $page := .page }}
|
|
{{- $page.Page.Store.Set (printf "%sIsNested" (partial "output-format.hugo" $page)) true }}
|
|
{{- with $page }}
|
|
{{- $currentNode := . }}
|
|
{{- $isActive := .IsHome }}
|
|
{{- $isShortcut := false }}
|
|
{{- with .Site.Menus.shortcuts }}
|
|
{{- range sort . "Weight" }}
|
|
{{- $shortcut := . }}
|
|
{{- $shortcutPage := $page.Site.GetPage (printf "%s" $shortcut.URL ) }}
|
|
{{- if and $shortcutPage (eq $shortcutPage.RelPermalink $page.RelPermalink) }}
|
|
{{- $isShortcut = true }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- $pages := .Site.Home.Sections }}
|
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
|
{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
|
|
{{- if $isShortcut }}
|
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
|
{{- else }}
|
|
{{- if $isActive }}
|
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
|
{{- if or $pages }}
|
|
<section>
|
|
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if eq $currentOrdersectionsby "title" }}
|
|
{{- range $pages.ByTitle }}
|
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
|
{{- end }}
|
|
{{- else }}
|
|
{{- range $pages.ByWeight }}
|
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if $isActive }}
|
|
{{- if $pages }}
|
|
</section>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- define "section-tree-print" }}
|
|
{{- $currentNode := .currentnode }}
|
|
{{- $isActive := .isActive }}
|
|
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}
|
|
{{- with .sect }}
|
|
{{- $isSelf := eq .RelPermalink $currentFileRelPermalink }}
|
|
{{- $isAncestor := and (not $isSelf) (.IsAncestor $currentNode) }}
|
|
{{- $isActive = or $isSelf $isActive }}
|
|
{{- $pages := .Pages }}
|
|
{{- if .Page.IsHome }}
|
|
{{- $pages = .Sections }}
|
|
{{- else if .Page.Sections}}
|
|
{{- $pages = (.Pages | union .Sections) }}
|
|
{{- end }}
|
|
{{- $relearnIsHiddenFrom := index ($currentNode.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
|
|
{{- $hidden := and $relearnIsHiddenFrom (not $.showhidden) (not $isSelf) (not $isAncestor) }}
|
|
{{- if $hidden }}
|
|
{{- else if or .IsSection .IsHome }}
|
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
|
{{- $currentOrdersectionsby := .Params.ordersectionsby | default $defaultOrdersectionsby }}
|
|
{{- if $isActive }}
|
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
|
{{- if $pages }}
|
|
<section>
|
|
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if eq $currentOrdersectionsby "title" }}
|
|
{{- range $pages.ByTitle }}
|
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
|
{{- end }}
|
|
{{- else }}
|
|
{{- range $pages.ByWeight }}
|
|
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- if $isActive }}
|
|
{{- if $pages }}
|
|
</section>
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- else }}
|
|
{{- if $isActive }}
|
|
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- end }}
|
|
{{- define "section-print" }}
|
|
{{- $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")) }}
|
|
{{- $currentNode.Page.Store.Set "nestedHasSwagger" (or ($currentNode.Page.Store.Get "nestedHasSwagger") (.Page.Store.Get "hasSwagger")) }}
|
|
{{- end }}
|
|
{{- end }} |