book_sidebar.html 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <form class="docs-search d-flex align-items-center">
  2. <button class="btn docs-toggle d-md-none p-0 mr-3" type="button" data-toggle="collapse" data-target="#docs-nav" aria-controls="docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
  3. <span><i class="fas fa-bars"></i></span>
  4. </button>
  5. {{ if eq site.Params.search.engine 1 }}
  6. <input name="q" type="search" class="form-control" placeholder="{{ i18n "search_placeholder" }}" autocomplete="off">
  7. {{ end }}
  8. </form>
  9. <nav class="collapse docs-links" id="docs-nav">
  10. {{ $current_node := . }}
  11. {{ $menu_name := "" }}
  12. {{ $order_by := site.Params.books.order_by | default "weight" }}
  13. {{ $query := "" }}
  14. {{ $root_page := .GetPage "/_index.md" }}
  15. {{ $is_root := false}}
  16. {{ if $root_page | and (eq $root_page.Type "book") }}
  17. {{ $is_root = true}}
  18. <ul class="nav docs-sidenav">
  19. <li class="{{ if .IsHome }}active{{ end }}"><a href="{{ $root_page.RelPermalink }}">{{$root_page.Title}}</a></li>
  20. </ul>
  21. {{- if eq $order_by "title" -}}
  22. {{- $query = .Site.Home.Sections.ByTitle -}}
  23. {{- else if eq $order_by "title_desc" -}}
  24. {{- $query = .Site.Home.Sections.ByTitle.Reverse -}}
  25. {{- else -}}
  26. {{- $query = .Site.Home.Sections.ByWeight -}}
  27. {{- end}}
  28. {{else}}
  29. {{/* Get section name from the path. */}}
  30. {{ $menu_name = (path.Base (path.Split .FirstSection).Dir) }}
  31. {{/* For any folder named `updates`, use descending title order (e.g. latest release note first). */}}
  32. {{ $order_by = cond (eq $menu_name "updates") "title_desc" $order_by }}
  33. {{- if eq $order_by "title" -}}
  34. {{- $query = where .Site.Home.Sections.ByTitle "Section" $menu_name -}}
  35. {{- else if eq $order_by "title_desc" -}}
  36. {{- $query = where .Site.Home.Sections.ByTitle.Reverse "Section" $menu_name -}}
  37. {{- else -}}
  38. {{- $query = where .Site.Home.Sections.ByWeight "Section" $menu_name -}}
  39. {{- end}}
  40. {{end}}
  41. {{- range $query -}}
  42. {{ template "book-menu" dict "sect" . "current_node" $current_node "order_by" $order_by "is_root" $is_root }}
  43. {{- end -}}
  44. </nav>