You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

shared.html 1.0KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. {{/*These templates contains some more complex logic and shared between partials*/}}
  2. {{- define "title" -}}
  3. {{- if .Pages -}}
  4. {{ $sections := split (trim .Dir "/") "/" }}
  5. {{ $title := index ($sections | last 1) 0 | humanize | title }}
  6. {{- default $title .Title -}}
  7. {{- else -}}
  8. {{ $title := .File | humanize | title }}
  9. {{- default $title .Title -}}
  10. {{- end -}}
  11. {{- end -}}
  12. {{- define "hrefhack" -}}
  13. {{ $attrEq := "$=" }}
  14. {{ $attrVal := .RelPermalink }}
  15. {{ if eq .RelPermalink "/" }}
  16. {{ $attrEq = "=" }}
  17. {{ $attrVal = .Permalink }}
  18. {{ end }}
  19. <style>
  20. nav ul a[href{{ $attrEq }}"{{ $attrVal }}"] {
  21. color: {{ default "#004ed0" .Site.Params.BookMenuBundleActiveLinkColor }};
  22. }
  23. </style>
  24. {{- end -}}
  25. {{- define "jsmenu" -}}
  26. <script>
  27. (function() {
  28. var menu = document.querySelector('aside.book-menu nav')
  29. addEventListener('beforeunload', function(event) {
  30. localStorage.setItem('menu.scrollTop', menu.scrollTop)
  31. });
  32. menu.scrollTop = localStorage.getItem('menu.scrollTop')
  33. })()
  34. </script>
  35. {{- end -}}