hugo-book-theme/layouts/partials/docs/shared.html

39 lines
1.1 KiB
HTML
Raw Normal View History

{{/*These templates contains some more complex logic and shared between partials*/}}
{{- define "title" -}}
{{- if and .File .Pages -}}
{{ $sections := split (trim .File.Dir "/") "/" }}
{{ $title := index ($sections | last 1) 0 | humanize | title }}
2018-09-18 01:35:54 +02:00
{{- default $title .Title -}}
{{- else if .File -}}
{{ $title := .File | humanize | title }}
2018-09-18 01:35:54 +02:00
{{- default $title .Title -}}
{{- end -}}
{{- end -}}
2019-02-13 23:31:13 +01:00
{{- define "hrefhack" -}}
2019-02-13 23:31:13 +01:00
{{ $attrEq := "$=" }}
{{ $attrVal := .RelPermalink }}
{{ if eq .RelPermalink "/" }}
{{ $attrEq = "=" }}
{{ $attrVal = .Permalink }}
{{ end }}
<style>
nav ul a[href{{ $attrEq }}"{{ $attrVal }}"] {
color: {{ default "#004ed0" .Site.Params.BookMenuBundleActiveLinkColor }};
}
</style>
{{- end -}}
{{- 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 -}}