Skip to content

Commit

Permalink
print: don't print rest of site for shortcut links matcornic#283
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Jun 23, 2022
1 parent 5ff0863 commit 3e48914
Showing 1 changed file with 21 additions and 16 deletions.
37 changes: 21 additions & 16 deletions layouts/partials/body.print.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,40 @@
{{- $currentNode := . }}
{{- $isActive := .IsHome }}
{{- $isShortcut := false }}
{{- $r_url := .RelPermalink }}
{{- with .Site.Menus.shortcuts }}
{{- range sort . "Weight" }}
{{- $s_url := .URL | relLangURL }}
{{- if (eq $s_url $r_url) }}
{{- $isActive = true }}
{{- $isShortcut = true }}
{{- end }}
{{- end }}
{{- end }}
{{- $pages := .Site.Home.Sections }}
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
{{- $currentOrdersectionsby := .Site.Home.Params.ordersectionsby | default $defaultOrdersectionsby }}
{{- if $isActive }}
{{- if $isShortcut }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- if or .IsHome .Params.chapter $pages }}
<section>
{{- 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 }}
{{- if $isActive }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- if or .IsHome .Params.chapter $pages }}
<section>
{{- end }}
{{- end }}
{{- end }}
{{- if $isActive }}
{{- if or .IsHome .Params.chapter $pages }}
</section>
{{- 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 or .IsHome .Params.chapter $pages }}
</section>
{{- end }}
{{- end }}
{{- end }}
{{- define "section-tree-print" }}
Expand Down

0 comments on commit 3e48914

Please sign in to comment.