mirror of
https://github.com/McShelby/hugo-theme-relearn.git
synced 2024-11-27 01:33:04 +00:00
Merge branch 'helfper-fix-index-json-encoding'
This commit is contained in:
commit
a57b650388
4 changed files with 64 additions and 65 deletions
|
@ -23,6 +23,8 @@ Note that some of these parameters are explained in details in other sections of
|
|||
showVisitedLinks = false
|
||||
# Disable search function. It will hide search bar
|
||||
disableSearch = false
|
||||
# Disable search in hidden pages, otherwise they will be shown in search box
|
||||
disableSearchHiddenPages = false
|
||||
# Javascript and CSS cache are automatically busted when new version of site is generated.
|
||||
# Set this to true to disable this behavior (some proxies don't handle well this optimization)
|
||||
disableAssetsBusting = false
|
||||
|
|
|
@ -1,12 +1,7 @@
|
|||
[{{ range $index, $page := .Site.Pages }}
|
||||
{{- if ne $page.Type "json" -}}
|
||||
{{- if and $index (gt $index 0) -}},{{- end }}
|
||||
{
|
||||
"uri": "{{ $page.RelPermalink }}",
|
||||
"title": "{{ htmlEscape $page.Title}}",
|
||||
"tags": [{{ range $tindex, $tag := $page.Params.tags }}{{ if $tindex }}, {{ end }}"{{ $tag| htmlEscape }}"{{ end }}],
|
||||
"description": "{{ htmlEscape .Description}}",
|
||||
"content": {{$page.Plain | jsonify}}
|
||||
}
|
||||
{{- end -}}
|
||||
{{- end -}}]
|
||||
{{- $pages := slice }}
|
||||
{{- range .Site.Pages }}
|
||||
{{- if or (ne (.Scratch.Get "relearnIsHiddenTree") true) (ne .Site.Params.disableSearchHiddenPages true) }}
|
||||
{{- $pages = $pages | append (dict "uri" .RelPermalink "title" .Title "tags" .Params.tags "description" .Description "content" (.Plain | htmlUnescape)) }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- $pages | jsonify (dict "indent" " ") }}
|
||||
|
|
|
@ -7,63 +7,12 @@
|
|||
|
||||
<div id="navigation">
|
||||
<!-- Next prev page -->
|
||||
{{ $currentNode := . }}
|
||||
|
||||
{{ $currentNode.Scratch.Set "selfFound" nil }}
|
||||
{{ $currentNode.Scratch.Set "prevPage" nil }}
|
||||
{{ $currentNode.Scratch.Set "nextPage" nil }}
|
||||
{{ template "menu-nextprev" dict "menu" .Site.Home "currentnode" $currentNode "hidden" false }}
|
||||
|
||||
{{ define "menu-nextprev" }}
|
||||
{{ $currentNode := .currentnode }}
|
||||
{{ $isSelf := eq $currentNode.RelPermalink .menu.RelPermalink }}
|
||||
{{ $isDescendant := and (not $isSelf) (.menu.IsDescendant $currentNode) }}
|
||||
{{ $isAncestor := and (not $isSelf) (.menu.IsAncestor $currentNode) }}
|
||||
{{ $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
|
||||
|
||||
{{ if $isSelf }}
|
||||
{{ $currentNode.Scratch.Set "selfFound" true }}
|
||||
{{end}}
|
||||
{{ $isSelfFound := eq ($currentNode.Scratch.Get "selfFound") true }}
|
||||
{{ $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
|
||||
{{ $isPostSelf := and ($isSelfFound) (not $isSelf) }}
|
||||
|
||||
{{ $page_hidden := or (.menu.Params.hidden) (eq .menu.Title "") }}
|
||||
{{ $hidden := or (and $page_hidden (not $isAncestor) (not $isSelf) ) (and .hidden (or $isPreSelf $isPostSelf $isDescendant) ) }}
|
||||
|
||||
{{ if not $hidden }}
|
||||
{{if and $isPreSelf (or $isOther $isAncestor ) }}
|
||||
{{ $currentNode.Scratch.Set "prevPage" .menu }}
|
||||
{{else if and $isPostSelf (or $isOther $isDescendant) (eq ($currentNode.Scratch.Get "nextPage") nil) }}
|
||||
{{ $currentNode.Scratch.Set "nextPage" .menu }}
|
||||
{{end}}
|
||||
{{ end }}
|
||||
|
||||
{{ $currentNode.Scratch.Set "pages" .menu.Pages }}
|
||||
{{ if .menu.IsHome}}
|
||||
{{ $currentNode.Scratch.Set "pages" .menu.Sections }}
|
||||
{{ else if .menu.Sections}}
|
||||
{{ $currentNode.Scratch.Set "pages" (.menu.Pages | union .menu.Sections) }}
|
||||
{{end}}
|
||||
{{ $pages := ($currentNode.Scratch.Get "pages") }}
|
||||
|
||||
{{if eq .Site.Params.ordersectionsby "title"}}
|
||||
{{ range $pages.ByTitle }}
|
||||
{{ template "menu-nextprev" dict "menu" . "currentnode" $currentNode "hidden" $hidden }}
|
||||
{{end}}
|
||||
{{else}}
|
||||
{{ range $pages.ByWeight }}
|
||||
{{ template "menu-nextprev" dict "menu" . "currentnode" $currentNode "hidden" $hidden }}
|
||||
{{end}}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{$showPrevNext := (and (not .Params.disableNextPrev) (not .Site.Params.disableNextPrev))}}
|
||||
{{if $showPrevNext}}
|
||||
{{with ($.Scratch.Get "prevPage")}}
|
||||
{{with ($.Scratch.Get "relearnPrevPage")}}
|
||||
<a class="nav nav-prev" href="{{.RelPermalink}}" title="{{.Title}}"><i class="fa fa-chevron-left"></i></a>
|
||||
{{end}}
|
||||
{{with ($.Scratch.Get "nextPage")}}
|
||||
{{with ($.Scratch.Get "relearnNextPage")}}
|
||||
<a class="nav nav-next" href="{{.RelPermalink}}" title="{{.Title}}"><i class="fa fa-chevron-right"></i></a>
|
||||
{{end}}
|
||||
{{end}}
|
||||
|
|
|
@ -38,6 +38,59 @@
|
|||
</style>
|
||||
{{ partial "custom-header.html" . }}
|
||||
</head>
|
||||
{{- $currentNode := . }}
|
||||
{{- $currentNode.Scratch.Set "relearnIsSelfFound" nil }}
|
||||
{{- $currentNode.Scratch.Set "relearnPrevPage" nil }}
|
||||
{{- $currentNode.Scratch.Set "relearnNextPage" nil }}
|
||||
{{- template "relearn-structure" dict "node" .Site.Home "currentnode" $currentNode "hidden" false }}
|
||||
|
||||
{{- define "relearn-structure" }}
|
||||
{{- $currentNode := .currentnode }}
|
||||
{{- $isSelf := eq $currentNode.RelPermalink .node.RelPermalink }}
|
||||
{{- $isDescendant := and (not $isSelf) (.node.IsDescendant $currentNode) }}
|
||||
{{- $isAncestor := and (not $isSelf) (.node.IsAncestor $currentNode) }}
|
||||
{{- $isOther := and (not $isDescendant) (not $isSelf) (not $isAncestor) }}
|
||||
|
||||
{{- if $isSelf }}
|
||||
{{- $currentNode.Scratch.Set "relearnIsSelfFound" true }}
|
||||
{{- end}}
|
||||
{{- $isSelfFound := eq ($currentNode.Scratch.Get "relearnIsSelfFound") true }}
|
||||
{{- $isPreSelf := and (not $isSelfFound) (not $isSelf) }}
|
||||
{{- $isPostSelf := and ($isSelfFound) (not $isSelf) }}
|
||||
|
||||
{{- $hidden_node := or (.node.Params.hidden) (eq .node.Title "") }}
|
||||
{{- $hidden_tree:= or $hidden_node .hidden }}
|
||||
{{- $hidden_from_current := or (and $hidden_node (not $isAncestor) (not $isSelf) ) (and .hidden (or $isPreSelf $isPostSelf $isDescendant) ) }}
|
||||
{{- .node.Scratch.Set "relearnIsHiddenNode" $hidden_node}}
|
||||
{{- .node.Scratch.Set "relearnIsHiddenTree" $hidden_tree}}
|
||||
{{- .node.Scratch.Set "relearnIsHiddenFromCurrent" $hidden_from_current}}
|
||||
|
||||
{{- if not $hidden_from_current }}
|
||||
{{- if and $isPreSelf (or $isOther $isAncestor ) }}
|
||||
{{- $currentNode.Scratch.Set "relearnPrevPage" .node }}
|
||||
{{- else if and $isPostSelf (or $isOther $isDescendant) (eq ($currentNode.Scratch.Get "relearnNextPage") nil) }}
|
||||
{{- $currentNode.Scratch.Set "relearnNextPage" .node }}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
|
||||
{{- $currentNode.Scratch.Set "relearnSubPages" .node.Pages }}
|
||||
{{- if .node.IsHome}}
|
||||
{{- $currentNode.Scratch.Set "relearnSubPages" .node.Sections }}
|
||||
{{- else if .node.Sections}}
|
||||
{{- $currentNode.Scratch.Set "relearnSubPages" (.node.Pages | union .node.Sections) }}
|
||||
{{- end}}
|
||||
{{- $pages := ($currentNode.Scratch.Get "relearnSubPages") }}
|
||||
|
||||
{{- if eq .Site.Params.ordersectionsby "title"}}
|
||||
{{- range $pages.ByTitle }}
|
||||
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hidden" $hidden_from_current }}
|
||||
{{- end}}
|
||||
{{- else}}
|
||||
{{- range $pages.ByWeight }}
|
||||
{{- template "relearn-structure" dict "node" . "currentnode" $currentNode "hidden" $hidden_from_current }}
|
||||
{{- end}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
<body class="" data-url="{{ .RelPermalink }}">
|
||||
{{ partial "menu.html" . }}
|
||||
<section id="body">
|
||||
|
|
Loading…
Reference in a new issue