Skip to content

Commit

Permalink
theme: simplify pagesBy #685
Browse files Browse the repository at this point in the history
  • Loading branch information
McShelby committed Jul 21, 2024
1 parent 1b2e139 commit fe9d605
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 17 deletions.
4 changes: 2 additions & 2 deletions layouts/partials/menu.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<div id="R-content-wrapper" class="highlightable">
<div id="R-topics">
<ul class="enlarge morespace collapsible-menu">
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .Site.Home "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .Site.Home) }}
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default false }}
{{- range $pages }}
{{- template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks "alwaysopen" $defaultAlwaysopen }}
Expand Down Expand Up @@ -130,7 +130,7 @@
{{- $isSelf := eq .RelPermalink $currentFileRelPermalink }}
{{- $isAncestor := and (not $isSelf) (.IsAncestor $currentNode) }}
{{- $isActive := $isSelf }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .) }}
{{- $relearnIsHiddenFrom := index ($currentNode.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- $hidden := and $relearnIsHiddenFrom (not $.showhidden) (not $isSelf) (not $isAncestor) }}
{{- if $hidden }}
Expand Down
4 changes: 2 additions & 2 deletions layouts/partials/nested-article.hugo
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{- $page.Page.Store.Set (printf "%sIsNested" $outputFormat) true }}
{{- with $page }}
{{- $currentNode := . }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .) }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode "outputFormat" $outputFormat }}
{{- if $pages }}
<section>
Expand All @@ -23,7 +23,7 @@
{{- with .sect }}
{{- $isSelf := eq .RelPermalink $currentFileRelPermalink }}
{{- $isAncestor := and (not $isSelf) (.IsAncestor $currentNode) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .) }}
{{- $relearnIsHiddenFrom := index ($currentNode.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- $hidden := and $relearnIsHiddenFrom (not $.showhidden) (not $isSelf) (not $isAncestor) }}
{{- if $hidden }}
Expand Down
2 changes: 1 addition & 1 deletion layouts/partials/page-meta.hugo
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
{{- end }}
{{- end }}

{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .node "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .node) }}
{{- range $pages }}
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hiddenstem" $hidden_stem "hiddencurrent" $hidden_from_current }}
{{- end }}
Expand Down
10 changes: 0 additions & 10 deletions layouts/partials/pageHelper/pagesBy.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,4 @@
{{- $pages = $page.Pages }}
{{- end }}

{{- if not $hidden }}
{{- $nonhiddenpages := slice }}
{{- range $page := $pages }}
{{- if not (partial "pageHelper/isHidden.html" $page) }}
{{- $nonhiddenpages := $nonhiddenpages | append $page }}
{{- end }}
{{- end }}
{{- $pages = $nonhiddenpages }}
{{- end }}

{{- return $pages }}
4 changes: 2 additions & 2 deletions layouts/partials/shortcodes/children.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

{{- with $page }}
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .) }}
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "page" . }}
{{ (printf "</%s>" $containerstyle)|safeHTML }}
{{- end }}
Expand Down Expand Up @@ -66,7 +66,7 @@
{{- (printf "<%s>" $.containerstyle)|safeHTML }}
{{- end }}

{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" . "hidden" true) }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .) }}
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "page" $page }}

{{- if eq $.style "li" }}
Expand Down

0 comments on commit fe9d605

Please sign in to comment.