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 }}
{{- 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">
<channel>
<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" -}}
{{ printf "<atom:link href=%q rel=\"self\" type=%q />" .Permalink .MediaType | safeHTML }}
{{- end -}}
{{ range $pages }}
{{- if and .Permalink .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
{{- range $pages }}
{{- if and .Permalink .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
<item>
<title>{{ .Title }}</title>
<link>{{ .Permalink }}</link>
<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>
<description>{{ .Summary | html }}</description>
</item>
{{- end }}
{{ end }}
{{- end }}
</channel>
</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}}">
{{- 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>
{{- $currentNode.Scratch.Set "pages" .Pages }}
{{- if .Sections}}
{{- $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }}
{{- $pages := .Pages }}
{{- if .Page.IsHome }}
{{- $pages = .Sections }}
{{- else if .Page.Sections}}
{{- $pages = (.Pages | union .Sections) }}
{{- end }}
{{- $pages := ($currentNode.Scratch.Get "pages") }}
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }}
{{- if eq .Site.Params.ordersectionsby "title" }}
{{- range $pages.ByTitle }}

View file

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

View file

@ -7,20 +7,13 @@
{{- $containerstyle := .Get "containerstyle" | default "ul" }}
{{ (printf "<%s class=\"children children-%s children-sort-%s\">" $containerstyle $style $sortTerm)|safeHTML }}
{{- .Scratch.Set "pages" .Page.Pages }}
{{- $pages := .Page.Pages }}
{{- if .Page.IsHome }}
<!-- Add pages that are in root dir -->
{{- $rootPage := where .Page.Pages "Dir" "" }}
{{- .Scratch.Set "pages" (.Page.Sections | union $rootPage)}}
{{- else }}
{{- if .Page.Sections}}
{{- .Scratch.Set "pages" (.Page.Pages | union .Page.Sections) }}
{{- end }}
{{- $pages = .Page.Sections }}
{{- else if .Page.Sections}}
{{- $pages = (.Page.Pages | union .Page.Sections) }}
{{- end }}
{{- $pages := (.Scratch.Get "pages") }}
{{- 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 }}
{{- else if or (eq $sortTerm "name") (eq $sortTerm "title") }}
@ -69,14 +62,13 @@
{{- (printf "<%s>" $.containerstyle)|safeHTML }}
{{- end }}
{{- if .Sections }}
{{- .Scratch.Set "pages" (.Pages | union .Sections) }}
{{- else }}
{{- .Scratch.Set "pages" .Pages }}
{{- $pages := .Page.Pages }}
{{- if .Page.IsHome }}
{{- $pages = .Page.Sections }}
{{- else if .Page.Sections}}
{{- $pages = (.Page.Pages | union .Page.Sections) }}
{{- end }}
{{- $pages := (.Scratch.Get "pages") }}
{{- 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 }}
{{- else if or (eq $.sortTerm "name") (eq $.sortTerm "title") }}