hugo-theme-relearn/layouts/partials/relearn-meta.gotmpl

62 lines
No EOL
2.7 KiB
Go Template

<!--
@@@
lang: {{- .Site.LanguagePrefix }}
path: {{- .Path }}
kind: {{- .Kind }} ["home" "page" "section" "taxonomy" "term"]
layout: {{- .Layout }}
type: {{- .Type }} [frontmatter:type section "page"]
section: {{- .Section }}
@@@
-->
{{- $currentNode := . }}
{{- $forceContent := $currentNode.WordCount }}
{{- $currentNode.Scratch.Delete "relearnIsSelfFound" }}
{{- $currentNode.Scratch.Delete "relearnPrevPage" }}
{{- $currentNode.Scratch.Delete "relearnNextPage" }}
{{- if (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev)) }}
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }}
{{- if not ($currentNode.Scratch.Get "relearnIsSelfFound") }}
{{- if not $currentNode.IsHome }}
{{- $currentNode.Scratch.Set "relearnPrevPage" .Site.Home }}
{{- end }}
{{- end }}
{{- end }}
{{- define "relearn-structure" }}
{{- $currentNode := .currentnode }}
{{- $isSelf := eq $currentNode .node }}
{{- $isDescendant := and (not $isSelf) (.node.IsDescendant $currentNode) }}
{{- $isAncestor := and (not $isSelf) (.node.IsAncestor $currentNode) }}
{{- $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
{{- $isChildren := eq $currentNode .node.Parent }}
{{- if $isSelf }}
{{- $currentNode.Scratch.Set "relearnIsSelfFound" true }}
{{- end }}
{{- $isSelfFound := eq ($currentNode.Scratch.Get "relearnIsSelfFound") true }}
{{- $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
{{- $isPostSelf := and ($isSelfFound) (not $isSelf) }}
{{- $hidden_node := or (.node.Params.hidden) (eq .node.Title "") }}
{{- $hidden_stem := or $hidden_node .hiddenstem }}
{{- $hidden_from_current := or (and $hidden_node (not $isAncestor) (not $isSelf) ) (and .hiddencurrent (or $isPreSelf $isPostSelf $isDescendant) ) }}
{{- if or (eq $currentNode.Kind "home") (eq $currentNode.Kind "section") (eq $currentNode.Kind "page") }}
{{- if not $hidden_from_current }}
{{- if and $isPreSelf .node.RelPermalink }}
{{- $currentNode.Scratch.Set "relearnPrevPage" .node }}
{{- else if and $isPostSelf .node.RelPermalink (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
{{- $currentNode.Scratch.Set "relearnNextPage" .node }}
{{- end }}
{{- end }}
{{- end }}
{{- if not ($currentNode.Scratch.Get "relearnNextPage") }}
{{- $pages := partialCached "_relearn/pages.gotmpl" (dict "page" .node) .node.Path }}
{{- range $pages }}
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current }}
{{- if $currentNode.Scratch.Get "relearnNextPage" }}
{{- break }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}