print: don't print rest of site for shortcut links #283

This commit is contained in:
Sören Weber 2022-06-23 19:45:52 +02:00
parent 5ff086306a
commit 3e489145e7
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589

View file

@ -1,36 +1,41 @@
{{- $currentNode := . }} {{- $currentNode := . }}
{{- $isActive := .IsHome }} {{- $isActive := .IsHome }}
{{- $isShortcut := false }}
{{- $r_url := .RelPermalink }} {{- $r_url := .RelPermalink }}
{{- with .Site.Menus.shortcuts }} {{- with .Site.Menus.shortcuts }}
{{- range sort . "Weight" }} {{- range sort . "Weight" }}
{{- $s_url := .URL | relLangURL }} {{- $s_url := .URL | relLangURL }}
{{- if (eq $s_url $r_url) }} {{- if (eq $s_url $r_url) }}
{{- $isActive = true }} {{- $isShortcut = true }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- $pages := .Site.Home.Sections }} {{- $pages := .Site.Home.Sections }}
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }} {{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }} {{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
{{- if $isActive }} {{- if $isShortcut }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- else }}
{{- if $isActive }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }} {{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- if or .IsHome .Params.chapter $pages }} {{- if or .IsHome .Params.chapter $pages }}
<section> <section>
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if eq $currentOrdersectionsby "title" }} {{- if eq $currentOrdersectionsby "title" }}
{{- range $pages.ByTitle }} {{- range $pages.ByTitle }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }} {{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
{{- end }} {{- end }}
{{- else }} {{- else }}
{{- range $pages.ByWeight }} {{- range $pages.ByWeight }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }} {{- template "section-tree-print" dict "sect" . "currentnode" $currentNode "isActive" $isActive }}
{{- end }} {{- end }}
{{- end }} {{- end }}
{{- if $isActive }} {{- if $isActive }}
{{- if or .IsHome .Params.chapter $pages }} {{- if or .IsHome .Params.chapter $pages }}
</section> </section>
{{- end }} {{- end }}
{{- end }}
{{- end }} {{- end }}
{{- define "section-tree-print" }} {{- define "section-tree-print" }}
{{- $currentNode := .currentnode }} {{- $currentNode := .currentnode }}