mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-22 23:37:53 +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 }}
|
||||
{{- $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) }}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
{{- $page := dict
|
||||
"content" $content
|
||||
"kind" "page"
|
||||
"outputs" (slice "html")
|
||||
"path" "_relearn_searchpage"
|
||||
"title" (T "Search")
|
||||
"url" $url
|
||||
|
|
|
@ -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) ) }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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 }}
|
||||
|
|
|
@ -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 }}">
|
||||
|
|
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 }}
|
||||
{{- 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" }}
|
||||
{{- $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 }}
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in a new issue