mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
search: special handling for generated page #888
This commit is contained in:
parent
ac4faed5d8
commit
a467f6f087
12 changed files with 38 additions and 26 deletions
|
@ -1,7 +1,8 @@
|
||||||
{{- partialCached "page-meta.hugo" . .RelPermalink }}
|
{{- partialCached "page-meta.hugo" . .RelPermalink }}
|
||||||
{{- $pages := slice }}
|
{{- $pages := slice }}
|
||||||
{{- range .Site.Pages }}
|
{{- 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 }}
|
{{- $tags := slice }}
|
||||||
{{- range .GetTerms "tags" }}
|
{{- range .GetTerms "tags" }}
|
||||||
{{- $tags = $tags | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify) }}
|
{{- $tags = $tags | append (partial "pageHelper/title.hugo" (dict "page" .Page "linkTitle" true) | plainify) }}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
{{- $page := dict
|
{{- $page := dict
|
||||||
"content" $content
|
"content" $content
|
||||||
"kind" "page"
|
"kind" "page"
|
||||||
|
"outputs" (slice "html")
|
||||||
"path" "_relearn_searchpage"
|
"path" "_relearn_searchpage"
|
||||||
"title" (T "Search")
|
"title" (T "Search")
|
||||||
"url" $url
|
"url" $url
|
||||||
|
|
|
@ -42,7 +42,9 @@
|
||||||
{{- range $pages }}
|
{{- range $pages }}
|
||||||
{{- $visible := true }}
|
{{- $visible := true }}
|
||||||
{{- $relearnIsHiddenFrom := index ($page.Scratch.Get "relearnIsHiddenFrom") .RelPermalink }}
|
{{- $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) ) }}
|
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}
|
{{- $visible = and .Title .Permalink (or (not $relearnIsHiddenFrom) (ne .Site.Params.disableSeoHiddenPages true) ) }}
|
||||||
|
|
|
@ -3,7 +3,8 @@
|
||||||
{{- printf "<?xml version=\"1.0\" encoding=\"utf-8\" standalone=\"yes\" ?>" | safeHTML }}
|
{{- 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">
|
<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 }}
|
{{- 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>
|
<url>
|
||||||
<loc>{{ partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true) }}</loc>{{ if not .Lastmod.IsZero }}
|
<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 }}
|
<lastmod>{{ safeHTML ( .Lastmod.Format "2006-01-02T15:04:05-07:00" ) }}</lastmod>{{ end }}{{ with .Sitemap.ChangeFreq }}
|
||||||
|
|
|
@ -14,7 +14,9 @@
|
||||||
{{- $breadcrumb := slice }}
|
{{- $breadcrumb := slice }}
|
||||||
{{- range seq $depth }}
|
{{- range seq $depth }}
|
||||||
{{- if $to }}
|
{{- 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 }}
|
{{- $breadcrumb = $breadcrumb | append $to }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
{{- range .AlternativeOutputFormats }}
|
{{- range .AlternativeOutputFormats }}
|
||||||
{{- if eq .Rel "canonical" }}
|
{{- if eq .Rel "canonical" }}
|
||||||
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" . "abs" true)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
{{ (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 }}
|
{{ (printf $link (partial "relLangPrettyUglyURL.hugo" (dict "to" .)) .Rel .MediaType.Type ($title | htmlEscape)) | safeHTML }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -1,20 +1,5 @@
|
||||||
{{- $page := .page }}
|
{{- .page.Page.Store.Set "relearnIsNested" true }}
|
||||||
{{- $page.Page.Store.Set "relearnIsNested" true }}
|
{{- template "section-tree-print" dict "sect" .page "currentnode" .page }}
|
||||||
{{- 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 }}
|
|
||||||
{{- define "section-tree-print" }}
|
{{- define "section-tree-print" }}
|
||||||
{{- $currentNode := .currentnode }}
|
{{- $currentNode := .currentnode }}
|
||||||
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}
|
{{- $currentFileRelPermalink := .currentnode.RelPermalink }}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
<meta property="og:locale" content="{{ replace . `-` `_` }}">
|
<meta property="og:locale" content="{{ replace . `-` `_` }}">
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if .IsPage }}
|
{{- if and .IsPage (not (partial "pageHelper/isRelearnSpecialPage.html" .)) }}
|
||||||
<meta property="og:type" content="article">
|
<meta property="og:type" content="article">
|
||||||
{{- with .FirstSection }}
|
{{- with .FirstSection }}
|
||||||
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" .) | plainify }}">
|
<meta property="article:section" content="{{ partial "pageHelper/title.hugo" (dict "page" .) | plainify }}">
|
||||||
|
|
5
layouts/partials/pageHelper/isRelearnSpecialPage.html
Normal file
5
layouts/partials/pageHelper/isRelearnSpecialPage.html
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
{{- $ret := false }}
|
||||||
|
{{- if hasPrefix .Path "/_relearn" }}
|
||||||
|
{{- $ret = true }}
|
||||||
|
{{- end }}
|
||||||
|
{{- return $ret }}
|
|
@ -31,4 +31,11 @@
|
||||||
{{- $pages = $page.Pages }}
|
{{- $pages = $page.Pages }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- return $pages }}
|
{{- $filtered_pages := slice }}
|
||||||
|
{{- range $pages }}
|
||||||
|
{{- if not (partial "pageHelper/isRelearnSpecialPage.html" .) }}
|
||||||
|
{{- $filtered_pages = $filtered_pages | append . }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
|
{{- return $filtered_pages }}
|
|
@ -2,7 +2,11 @@
|
||||||
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
|
{{- $onwidthm := cond (isset . "onwidthm") .onwidthm "show" }}
|
||||||
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
|
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
|
||||||
{{- with .page }}
|
{{- 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 }}
|
{{- $filePath := printf "%s%s" (strings.TrimLeft "/" (replace .File.Dir "\\" "/")) .File.LogicalName }}
|
||||||
{{- $href := "" }}
|
{{- $href := "" }}
|
||||||
{{- if .Site.Params.editURL }}
|
{{- if .Site.Params.editURL }}
|
||||||
|
|
|
@ -3,7 +3,11 @@
|
||||||
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
|
{{- $onwidthl := cond (isset . "onwidthl") .onwidthl "show" }}
|
||||||
{{- with .page }}
|
{{- with .page }}
|
||||||
{{- $printFormat := .OutputFormats.Get "print" }}
|
{{- $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
|
{{- partial "topbar/func/button.html" (dict
|
||||||
"page" .
|
"page" .
|
||||||
"class" "topbar-button-print"
|
"class" "topbar-button-print"
|
||||||
|
|
Loading…
Reference in a new issue