hidden pages: streamlined pages collection #102

This commit is contained in:
Sören Weber 2021-09-27 21:06:00 +02:00
parent 7f0057bcd9
commit f35e2336aa
No known key found for this signature in database
GPG key ID: 07D17FF580AE7589
4 changed files with 34 additions and 40 deletions

View file

@ -1,17 +1,15 @@
{{- $pctx := . -}}
{{- if .IsHome -}}{{ $pctx = .Site }}{{- end -}}
{{- $pages := slice -}}
{{- if or $.IsHome $.IsSection -}}
{{- $pages = $pctx.RegularPages -}}
{{- else -}}
{{- $pages = $pctx.Pages -}}
{{- end -}}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 1 -}}
{{- $pages = $pages | first $limit -}}
{{- end -}}
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }} {{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\"?>" | safeHTML }}
{{- partial "page-meta.go" . }} {{- partial "page-meta.go" . }}
{{- $pages := .Page.Pages }}
{{- if .Page.IsHome }}
{{- $pages = .Page.Sections }}
{{- else if .Page.Sections}}
{{- $pages = (.Page.Pages | union .Page.Sections) }}
{{- end }}
{{- $limit := .Site.Config.Services.RSS.Limit -}}
{{- if ge $limit 0 -}}
{{- $pages = $pages | first $limit -}}
{{- end }}
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"> <rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom">
<channel> <channel>
<title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title> <title>{{ if eq .Title .Site.Title }}{{ .Site.Title }}{{ else }}{{ with .Title }}{{.}} on {{ end }}{{ .Site.Title }}{{ end }}</title>
@ -26,17 +24,19 @@
{{- with .OutputFormats.Get "RSS" -}} {{- with .OutputFormats.Get "RSS" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }} {{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}} {{- end -}}
{{ range $pages }} {{- range $pages }}
{{- if and .Permalink .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }} {{- if and .Permalink .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
<item> <item>
<title>{{ .Title }}</title> <title>{{ .Title }}</title>
<link>{{ .Permalink }}</link> <link>{{ .Permalink }}</link>
<pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate> <pubDate>{{ .Date.Format "Mon, 02 Jan 2006 15:04:05 -0700" | safeHTML }}</pubDate>
{{ with .Site.Author.email }}<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>{{end}} {{- with .Site.Author.email }}
<author>{{.}}{{ with $.Site.Author.name }} ({{.}}){{end}}</author>
{{- end }}
<guid>{{ .Permalink }}</guid> <guid>{{ .Permalink }}</guid>
<description>{{ .Summary | html }}</description> <description>{{ .Summary | html }}</description>
</item> </item>
{{- end }} {{- end }}
{{ end }} {{- end }}
</channel> </channel>
</rss> </rss>

View file

@ -109,11 +109,12 @@
<li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}{{if .IsAncestor $currentNode }} parent{{end}}{{if $currentAlwaysopen}} alwaysopen{{end}}"><a href="{{.RelPermalink}}"> <li data-nav-id="{{.RelPermalink}}" title="{{.Title}}" class="dd-item{{if eq .File.UniqueID $currentFileUniqueID}} active{{end}}{{if .IsAncestor $currentNode }} parent{{end}}{{if $currentAlwaysopen}} alwaysopen{{end}}"><a href="{{.RelPermalink}}">
{{- partial "menu-pre.html" . }}{{ or .Params.menuTitle .LinkTitle .Title }}{{ partial "menu-post.html" . }} {{- partial "menu-pre.html" . }}{{ or .Params.menuTitle .LinkTitle .Title }}{{ partial "menu-post.html" . }}
{{- if $showvisitedlinks }}<i class="fas fa-check read-icon"></i>{{ end }}</a><ul> {{- if $showvisitedlinks }}<i class="fas fa-check read-icon"></i>{{ end }}</a><ul>
{{- $currentNode.Scratch.Set "pages" .Pages }} {{- $pages := .Pages }}
{{- if .Sections}} {{- if .Page.IsHome }}
{{- $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }} {{- $pages = .Sections }}
{{- else if .Page.Sections}}
{{- $pages = (.Pages | union .Sections) }}
{{- end }} {{- end }}
{{- $pages := ($currentNode.Scratch.Get "pages") }}
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }} {{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }}
{{- if eq .Site.Params.ordersectionsby "title" }} {{- if eq .Site.Params.ordersectionsby "title" }}
{{- range $pages.ByTitle }} {{- range $pages.ByTitle }}

View file

@ -2,6 +2,7 @@
{{- $currentNode.Scratch.Set "relearnIsSelfFound" nil }} {{- $currentNode.Scratch.Set "relearnIsSelfFound" nil }}
{{- $currentNode.Scratch.Set "relearnPrevPage" nil }} {{- $currentNode.Scratch.Set "relearnPrevPage" nil }}
{{- $currentNode.Scratch.Set "relearnNextPage" nil }} {{- $currentNode.Scratch.Set "relearnNextPage" nil }}
{{- $currentNode.Scratch.Set "relearnSubPages" nil }}
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }} {{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hiddenstem" false "hiddencurrent" false }}
{{- define "relearn-structure" }} {{- define "relearn-structure" }}
{{- $currentNode := .currentnode }} {{- $currentNode := .currentnode }}
@ -34,11 +35,11 @@
{{- end }} {{- end }}
{{- $currentNode.Scratch.Set "relearnSubPages" .node.Pages }} {{- $currentNode.Scratch.Set "relearnSubPages" .node.Pages }}
{{- if .node.IsHome}} {{- if .node.IsHome }}
{{- $currentNode.Scratch.Set "relearnSubPages" .node.Sections }} {{- $currentNode.Scratch.Set "relearnSubPages" .node.Sections }}
{{- else if .node.Sections}} {{- else if .node.Sections }}
{{- $currentNode.Scratch.Set "relearnSubPages" (.node.Pages | union .node.Sections) }} {{- $currentNode.Scratch.Set "relearnSubPages" (.node.Pages | union .node.Sections) }}
{{- end}} {{- end }}
{{- $pages := ($currentNode.Scratch.Get "relearnSubPages") }} {{- $pages := ($currentNode.Scratch.Get "relearnSubPages") }}
{{- if eq .Site.Params.ordersectionsby "title"}} {{- if eq .Site.Params.ordersectionsby "title"}}

View file

@ -7,20 +7,13 @@
{{- $containerstyle := .Get "containerstyle" | default "ul" }} {{- $containerstyle := .Get "containerstyle" | default "ul" }}
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }} {{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
{{- .Scratch.Set "pages" .Page.Pages }} {{- $pages := .Page.Pages }}
{{- if .Page.IsHome }} {{- if .Page.IsHome }}
<!-- Add pages that are in root dir --> {{- $pages = .Page.Sections }}
{{- $rootPage := where .Page.Pages "Dir" "" }} {{- else if .Page.Sections}}
{{- .Scratch.Set "pages" (.Page.Sections | union $rootPage)}} {{- $pages = (.Page.Pages | union .Page.Sections) }}
{{- else }}
{{- if .Page.Sections}}
{{- .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
{{- end }}
{{- end }} {{- end }}
{{- $pages := (.Scratch.Get "pages") }}
{{- if eq $sortTerm "weight" }} {{- if eq $sortTerm "weight" }}
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }} {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
{{- else if or (eq $sortTerm "name") (eq $sortTerm "title") }} {{- else if or (eq $sortTerm "name") (eq $sortTerm "title") }}
@ -69,14 +62,13 @@
{{- (printf "<%s>" $.containerstyle)|safeHTML }} {{- (printf "<%s>" $.containerstyle)|safeHTML }}
{{- end }} {{- end }}
{{- if .Sections }} {{- $pages := .Page.Pages }}
{{- .Scratch.Set "pages" (.Pages | union .Sections) }} {{- if .Page.IsHome }}
{{- else }} {{- $pages = .Page.Sections }}
{{- .Scratch.Set "pages" .Pages }} {{- else if .Page.Sections}}
{{- $pages = (.Page.Pages | union .Page.Sections) }}
{{- end }} {{- end }}
{{- $pages := (.Scratch.Get "pages") }}
{{- if eq $.sortTerm "weight" }} {{- if eq $.sortTerm "weight" }}
{{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }} {{- template "childs" dict "menu" $pages.ByWeight "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
{{- else if or (eq $.sortTerm "name") (eq $.sortTerm "title") }} {{- else if or (eq $.sortTerm "name") (eq $.sortTerm "title") }}