mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-23 07:47:54 +00:00
theme: allow menu items and children to be served by file:// protocol #375
This commit is contained in:
parent
e6a06b8854
commit
de3d3f598d
4 changed files with 23 additions and 21 deletions
|
@ -1,6 +1,7 @@
|
||||||
{{- partial "page-meta.hugo" . }}
|
{{- partial "page-meta.hugo" . }}
|
||||||
{{- partial "header.html" . }}
|
{{- partial "header.html" . }}
|
||||||
<article>
|
<article>
|
||||||
|
{{- $page := . }}
|
||||||
|
|
||||||
<h1>{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}</h1>
|
<h1>{{ if eq .Kind "term" }}{{ .Data.Singular | humanize }} {{ default "::" .Site.Params.titleSeparator }} {{ end }}{{ .Title }}</h1>
|
||||||
<ul>
|
<ul>
|
||||||
|
@ -12,12 +13,12 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if $len }}
|
{{- if $len }}
|
||||||
<li><a href="{{ .Page.RelPermalink }}">{{ .Page.Title }}</a> ({{ $len }})</li>
|
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $page "to" .Page) }}">{{ .Page.Title }}</a> ({{ $len }})</li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- range sort .Pages "Title" }}
|
{{- range sort .Pages "Title" }}
|
||||||
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
{{- if and .Title (or (ne (.Scratch.Get "relearnIsHiddenStem") true) (ne .Site.Params.disableTagHiddenPages true) ) }}
|
||||||
<li><a href="{{ .RelPermalink }}">{{ .Title }}</a></li>
|
<li><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $page "to" .) }}">{{ .Title }}</a></li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -154,7 +154,7 @@
|
||||||
{{- $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
|
{{- $currentAlwaysopen := .Params.alwaysopen | default $alwaysopen }}
|
||||||
{{- $pageHash := md5 .Page }}
|
{{- $pageHash := md5 .Page }}
|
||||||
{{- $isOpen := or $currentAlwaysopen $isSelf $isAncestor }}
|
{{- $isOpen := or $currentAlwaysopen $isSelf $isAncestor }}
|
||||||
<li data-nav-id="{{.RelPermalink}}" class="dd-item{{if $isActive }} active{{end}}{{if (or $isSelf $isAncestor) }} parent{{end}}{{if $currentAlwaysopen}} alwaysopen{{end}}">{{ if .Site.Params.collapsibleMenu }}<input type="checkbox" id="section-{{ $pageHash }}" aria-controls="subsections-{{ $pageHash }}" class="toggle"{{ if $isOpen }} checked{{ end }}><label class="a11y-only toggle" for="section-{{ $pageHash }}" >{{ T "Submenu" ( or .Params.menuTitle .LinkTitle .Title ) }}</label>{{ end }}<a href="{{.RelPermalink}}">
|
<li data-nav-id="{{.RelPermalink}}" class="dd-item{{if $isActive }} active{{end}}{{if (or $isSelf $isAncestor) }} parent{{end}}{{if $currentAlwaysopen}} alwaysopen{{end}}">{{ if .Site.Params.collapsibleMenu }}<input type="checkbox" id="section-{{ $pageHash }}" aria-controls="subsections-{{ $pageHash }}" class="toggle"{{ if $isOpen }} checked{{ end }}><label class="a11y-only toggle" for="section-{{ $pageHash }}" >{{ T "Submenu" ( or .Params.menuTitle .LinkTitle .Title ) }}</label>{{ end }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" .Page "to" .) }}">
|
||||||
{{- 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 id="subsections-{{ $pageHash }}">
|
{{- if $showvisitedlinks }}<i class="fas fa-check read-icon"></i>{{ end }}</a><ul id="subsections-{{ $pageHash }}">
|
||||||
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }}
|
{{- $defaultAlwaysopen := .Site.Params.alwaysopen | default true }}
|
||||||
|
@ -168,12 +168,12 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end }}</ul></li>
|
{{- end }}</ul></li>
|
||||||
{{- else }}
|
{{- else }}
|
||||||
<li data-nav-id="{{.RelPermalink}}" class="dd-item{{if $isActive }} active{{end}}"><a href="{{.RelPermalink}}">
|
<li data-nav-id="{{.RelPermalink}}" class="dd-item{{if $isActive }} active{{end}}"><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" .Page "to" .) }}">
|
||||||
{{- 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></li>
|
{{- if $showvisitedlinks }}<i class="fas fa-check read-icon"></i>{{ end }}</a></li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
<li data-nav-id="{{.RelPermalink}}" class="dd-item{{if $isActive }} active{{end}}"><a href="{{.RelPermalink}}">
|
<li data-nav-id="{{.RelPermalink}}" class="dd-item{{if $isActive }} active{{end}}"><a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" .Page "to" .) }}">
|
||||||
{{- 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></li>
|
{{- if $showvisitedlinks }}<i class="fas fa-check read-icon"></i>{{ end }}</a></li>
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{{- $page := .page }}
|
{{- $page := .page }}
|
||||||
{{- $to := .to }}
|
{{- $to := .to }}
|
||||||
{{- $link := $to.RelPermalink }}
|
{{- $link := $to.RelPermalink }}
|
||||||
{{- if and (ne .page.Site.Params.disableExplicitIndexURLs true) (eq (substr $link -1) "/") }}
|
{{- if and (ne $page.Site.Params.disableExplicitIndexURLs true) (eq (substr $link -1) "/") }}
|
||||||
{{- $link = printf "%sindex.html" $link }}
|
{{- $link = printf "%sindex.html" $link }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- $link }}
|
{{- $link }}
|
|
@ -27,22 +27,23 @@
|
||||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||||
{{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
{{- $currentOrdersectionsby := $sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||||
{{- if eq $currentOrdersectionsby "weight" }}
|
{{- if eq $currentOrdersectionsby "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 "context" . }}
|
||||||
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
|
{{- else if or (eq $currentOrdersectionsby "name") (eq $currentOrdersectionsby "title") }}
|
||||||
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
||||||
{{- else if eq $currentOrdersectionsby "publishdate" }}
|
{{- else if eq $currentOrdersectionsby "publishdate" }}
|
||||||
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
||||||
{{- else if eq $currentOrdersectionsby "date" }}
|
{{- else if eq $currentOrdersectionsby "date" }}
|
||||||
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
||||||
{{- else if eq $currentOrdersectionsby "length" }}
|
{{- else if eq $currentOrdersectionsby "length" }}
|
||||||
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm }}
|
{{- template "childs" dict "menu" $pages "containerstyle" $containerstyle "style" $style "showhidden" $showhidden "count" 1 "depth" $depth "pages" .Site.Pages "description" $withDescription "sortTerm" $sortTerm "context" . }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{ (printf "</%s>" $containerstyle)|safeHTML }}
|
{{ (printf "</%s>" $containerstyle)|safeHTML }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- define "childs" }}
|
{{- define "childs" }}
|
||||||
|
{{ $context := .context }}
|
||||||
{{- range .menu }}
|
{{- range .menu }}
|
||||||
{{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
{{- $hidden := and (or (.Params.hidden) (eq .Title "")) (not $.showhidden) }}
|
||||||
{{- if not $hidden }}
|
{{- if not $hidden }}
|
||||||
|
@ -50,7 +51,7 @@
|
||||||
{{- if hasPrefix $.style "h" }}
|
{{- if hasPrefix $.style "h" }}
|
||||||
{{- $num := sub ( int (trim $.style "h") ) 1 }}
|
{{- $num := sub ( int (trim $.style "h") ) 1 }}
|
||||||
{{- $numn := add $num $.count }}
|
{{- $numn := add $num $.count }}
|
||||||
{{ (printf "<h%d>" $numn)|safeHTML }}<a href="{{ .RelPermalink }}" >{{ .Title }}</a>{{ (printf "</h%d>" $numn)|safeHTML }}
|
{{ (printf "<h%d>" $numn)|safeHTML }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $context "to" .) }}">{{ .Title }}</a>{{ (printf "</h%d>" $numn)|safeHTML }}
|
||||||
{{- if $.description }}
|
{{- if $.description }}
|
||||||
{{- if .Description -}}
|
{{- if .Description -}}
|
||||||
<p>{{ .Description }}</p>
|
<p>{{ .Description }}</p>
|
||||||
|
@ -60,7 +61,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- else if eq $.style "li" }}
|
{{- else if eq $.style "li" }}
|
||||||
{{ (printf "<%s>" $.style)|safeHTML }}<a href="{{ .RelPermalink }}" >{{ .Title }}</a>
|
{{ (printf "<%s>" $.style)|safeHTML }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $context "to" .) }}">{{ .Title }}</a>
|
||||||
{{- if $.description }}
|
{{- if $.description }}
|
||||||
{{- if .Description -}}
|
{{- if .Description -}}
|
||||||
<p>{{ .Description }}</p>
|
<p>{{ .Description }}</p>
|
||||||
|
@ -70,7 +71,7 @@
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{ (printf "<%s>" $.style)|safeHTML }}<a href="{{ .RelPermalink }}" >{{ .Title }}</a>{{ (printf "</%s>" $.style)|safeHTML }}
|
{{ (printf "<%s>" $.style)|safeHTML }}<a href="{{ partial "relLangPrettyUglyURL.hugo" (dict "page" $context "to" .) }}">{{ .Title }}</a>{{ (printf "</%s>" $.style)|safeHTML }}
|
||||||
{{- if $.description }}
|
{{- if $.description }}
|
||||||
{{- if .Description -}}
|
{{- if .Description -}}
|
||||||
<p>{{ .Description }}</p>
|
<p>{{ .Description }}</p>
|
||||||
|
@ -97,17 +98,17 @@
|
||||||
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
{{- $defaultOrdersectionsby := .Site.Params.ordersectionsby | default "weight" }}
|
||||||
{{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
{{- $currentOrdersectionsby := $.sortTerm | default (.Page.Params.ordersectionsby | default $defaultOrdersectionsby) }}
|
||||||
{{- if eq $currentOrdersectionsby "weight" }}
|
{{- if eq $currentOrdersectionsby "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 "context" $context }}
|
||||||
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
|
{{- else if or (eq $.currentOrdersectionsby "name") (eq $.currentOrdersectionsby "title") }}
|
||||||
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByTitle "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
||||||
{{- else if eq $.currentOrdersectionsby "publishdate" }}
|
{{- else if eq $.currentOrdersectionsby "publishdate" }}
|
||||||
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByPublishDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
||||||
{{- else if eq $.currentOrdersectionsby "date" }}
|
{{- else if eq $.currentOrdersectionsby "date" }}
|
||||||
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByDate "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
||||||
{{- else if eq $.currentOrdersectionsby "length" }}
|
{{- else if eq $.currentOrdersectionsby "length" }}
|
||||||
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
{{- template "childs" dict "menu" $pages.ByLength "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm }}
|
{{- template "childs" dict "menu" $pages "containerstyle" $.containerstyle "style" $.style "showhidden" $.showhidden "count" (add $.count 1) "depth" $.depth "pages" $.pages "description" $.description "sortTerm" $.sortTerm "context" $context }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
{{- if eq $.style "li" }}
|
{{- if eq $.style "li" }}
|
||||||
|
|
Loading…
Reference in a new issue