#43, Update tree menu rendering to support multiple sections
This commit is contained in:
@@ -1,16 +1,16 @@
|
||||
{{/*These templates contains some more complex logic and shared between partials*/}}
|
||||
{{- define "title" -}}
|
||||
{{- if and .File .Pages -}}
|
||||
{{ define "title" }}
|
||||
{{ if and .File .Pages }}
|
||||
{{ $sections := split (trim .File.Dir "/") "/" }}
|
||||
{{ $title := index ($sections | last 1) 0 | humanize | title }}
|
||||
{{- default $title .Title -}}
|
||||
{{- else if .File -}}
|
||||
{{ $title := .File | humanize | title }}
|
||||
{{- default $title .Title -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{ default $title .Title }}
|
||||
{{ else if .File }}
|
||||
{{ $title := .File.BaseFileName | humanize | title }}
|
||||
{{ default $title .Title }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{- define "hrefhack" -}}
|
||||
{{ define "hrefhack" }}
|
||||
{{ $attrEq := "$=" }}
|
||||
{{ $attrVal := .RelPermalink }}
|
||||
{{ if eq .RelPermalink "/" }}
|
||||
@@ -23,17 +23,16 @@
|
||||
color: {{ default "#004ed0" .Site.Params.BookMenuBundleActiveLinkColor }};
|
||||
}
|
||||
</style>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
|
||||
{{- define "jsmenu" -}}
|
||||
{{ define "jsmenu" }}
|
||||
<script>
|
||||
(function() {
|
||||
var menu = document.querySelector('aside.book-menu nav')
|
||||
addEventListener('beforeunload', function(event) {
|
||||
localStorage.setItem('menu.scrollTop', menu.scrollTop)
|
||||
});
|
||||
|
||||
menu.scrollTop = localStorage.getItem('menu.scrollTop')
|
||||
})()
|
||||
</script>
|
||||
{{- end -}}
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user