search: special handling for generated page #888

This commit is contained in:
Sören Weber 2024-08-27 15:34:36 +02:00
parent ac4faed5d8
commit a467f6f087
No known key found for this signature in database
GPG key ID: BEC6D55545451B6D
12 changed files with 38 additions and 26 deletions

View file

@ -1,7 +1,8 @@
{{- partialCached "page-meta.hugo" . .RelPermalink }}
{{- $pages := slice }}
{{- range .Site.Pages }}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- if partial "pageHelper/isRelearnSpecialPage.html" . }}
{{- else if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSearchHiddenPages true) ) }}
{{- $tags := slice }}
{{- range .GetTerms "tags" }}
{{- $tags = $tags | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify) }}

View file

@ -8,6 +8,7 @@
{{- $page := dict
"content" $content
"kind" "page"
"outputs" (slice "html")
"path" "_relearn_searchpage"
"title" (T "Search")
"url" $url

View file

@ -42,7 +42,9 @@
{{- range $pages }}
{{- $visible := true }}
{{- $relearnIsHiddenFrom := index ($page.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
{{- if or (eq .Kind "taxonomy") (eq .Kind "term") }}
{{- if partial "pageHelper/isRelearnSpecialPage.html" . }}
{{- $visible = false }}
{{- else if or (eq .Kind "taxonomy") (eq .Kind "term") }}
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableTagHiddenPages true) ) }}
{{- else }}
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}

View file

@ -3,7 +3,8 @@
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml">
{{- range where .Pages "Sitemap.Disable" "ne" true }}
{{- if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
{{- if partial "pageHelper/isRelearnSpecialPage.html" . }}
{{- else if and .Title .RelPermalink (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableSeoHiddenPages true) ) }}
<url>
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>{{ if not .Lastmod.IsZero }}
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}

View file

@ -14,7 +14,9 @@
{{- $breadcrumb := slice }}
{{- range seq $depth }}
{{- if $to }}
{{- if or $to.Title (eq $to.Kind "taxonomy") (eq $to.Kind "term") }}
{{- if partial "pageHelper/isRelearnSpecialPage.html" $to }}
{{- break }}
{{- else if or $to.Title (eq $to.Kind "taxonomy") (eq $to.Kind "term") }}
{{- $breadcrumb = $breadcrumb | append $to }}
{{- end }}
{{- else }}

View file

@ -31,7 +31,7 @@
{{- range .AlternativeOutputFormats }}
{{- if eq .Rel "canonical" }}
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
{{- else }}
{{- else if not (partial "pageHelper/isRelearnSpecialPage.html" $page) }}
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
{{- end }}
{{- end }}

View file

@ -1,20 +1,5 @@
{{- $page := .page }}
{{- $page.Page.Store.Set "relearnIsNested" true }}
{{- with $page }}
{{- $currentNode := . }}
{{- $pages := partial "pageHelper/pagesBy.html" (dict "page" .) }}
{{- template "section-print" dict "sect" . "currentnode" $currentNode }}
{{- if $pages }}
<section>
<h1 class="a11y-only">{{ T "Subsections" .Title }}</h1>
{{- end }}
{{- range $pages }}
{{- template "section-tree-print" dict "sect" . "currentnode" $currentNode }}
{{- end }}
{{- if $pages }}
</section>
{{- end }}
{{- end }}
{{- .page.Page.Store.Set "relearnIsNested" true }}
{{- template "section-tree-print" dict "sect" .page "currentnode" .page }}
{{- define "section-tree-print" }}
{{- $currentNode := .currentnode }}
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}

View file

@ -17,7 +17,7 @@
<meta property="og:locale" content="{{ replace . `-` `_` }}">
{{- end }}
{{- if .IsPage }}
{{- if and .IsPage (not (partial "pageHelper/isRelearnSpecialPage.html" .)) }}
<meta property="og:type" content="article">
{{- with .FirstSection }}
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" .) | plainify }}">

View file

@ -0,0 +1,5 @@
{{- $ret := false }}
{{- if hasPrefix .Path "/_relearn" }}
{{- $ret = true }}
{{- end }}
{{- return $ret }}

View file

@ -31,4 +31,11 @@
{{- $pages = $page.Pages }}
{{- end }}
{{- return $pages }}
{{- $filtered_pages := slice }}
{{- range $pages }}
{{- if not (partial "pageHelper/isRelearnSpecialPage.html" .) }}
{{- $filtered_pages = $filtered_pages | append . }}
{{- end }}
{{- end }}
{{- return $filtered_pages }}

View file

@ -2,7 +2,11 @@
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }}
{{- if .File }}
{{- $show := .File }}
{{- if $show }}
{{- $show = not (partial "pageHelper/isRelearnSpecialPage.html" .) }}
{{- end }}
{{- if $show }}
{{- $filePath := printf "%s%s" (strings.TrimLeft "/" (replace .File.Dir "\\" "/")) .File.LogicalName }}
{{- $href := "" }}
{{- if .Site.Params.editURL }}

View file

@ -3,7 +3,11 @@
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
{{- with .page }}
{{- $printFormat := .OutputFormats.Get "print" }}
{{- if $printFormat }}
{{- $show := $printFormat }}
{{- if $show }}
{{- $show = not (partial "pageHelper/isRelearnSpecialPage.html" .) }}
{{- end }}
{{- if $show }}
{{- partial "topbar/func/button.html" (dict
"page" .
"class" "topbar-button-print"