mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-06 20:15:01 +00:00
94 lines
3.6 KiB
HTML
94 lines
3.6 KiB
HTML
<form class="docs-search d-flex align-items-center">
|
|
<button class="btn docs-toggle d-md-none p-0 mr-md-3 w-100" type="button" data-toggle="collapse" data-target="#docs-nav" aria-controls="docs-nav" aria-expanded="false" aria-label="Toggle section navigation">
|
|
<div class="d-flex">
|
|
<span class="d-md-none pl-1 flex-grow-1 text-left overflow-hidden">
|
|
{{ if .Parent | and .Parent.IsHome }}
|
|
{{ .LinkTitle | emojify }}
|
|
{{ else if .Parent | and (not .Parent.IsHome) }}
|
|
{{ .Parent.LinkTitle | emojify }}
|
|
{{ else }}
|
|
{{ (i18n "home" | default "Home") | emojify }}
|
|
{{ end }}
|
|
</span>
|
|
<span><i class="fas fa-chevron-down"></i></span>
|
|
</div>
|
|
</button>
|
|
|
|
{{ if eq (lower site.Params.search.provider) "wowchemy" }}
|
|
<button class="form-control sidebar-search js-search d-none d-md-flex">
|
|
<i class="fas fa-search pr-2"></i>
|
|
<span class="sidebar-search-text">{{ i18n "search_placeholder" }}</span>
|
|
<span class="sidebar-search-shortcut">/</span>
|
|
</button>
|
|
{{ end }}
|
|
</form>
|
|
|
|
<nav class="collapse docs-links" id="docs-nav">
|
|
{{ $current_node := . }}
|
|
{{ $menu_name := "" }}
|
|
{{ $order_by := site.Params.books.order_by | default "weight" }}
|
|
{{ $query := "" }}
|
|
{{ $root_page := .GetPage "/_index.md" }}
|
|
{{ $is_root := false}}
|
|
|
|
{{/* Case where homepage is a book */}}
|
|
{{ if $root_page | and (eq $root_page.Type "book") }}
|
|
{{ $is_root = true}}
|
|
<ul class="nav docs-sidenav">
|
|
<li class="{{ if .IsHome }}active{{ end }}"><a href="{{ $root_page.RelPermalink }}">{{$root_page.Title}}</a></li>
|
|
</ul>
|
|
{{- if eq $order_by "title" -}}
|
|
{{- $query = .Site.Home.Sections.ByTitle -}}
|
|
{{- else if eq $order_by "title_desc" -}}
|
|
{{- $query = .Site.Home.Sections.ByTitle.Reverse -}}
|
|
{{- else -}}
|
|
{{- $query = .Site.Home.Sections.ByWeight -}}
|
|
{{- end}}
|
|
|
|
{{else}}
|
|
{{/* Case where homepage is NOT a book */}}
|
|
|
|
{{ if eq .FirstSection.Type "book" }}
|
|
{{/* Case where first section is a book. */}}
|
|
|
|
{{ $menu_name = (path.Base (path.Split .FirstSection).Dir) }}
|
|
{{- if eq $order_by "title" -}}
|
|
{{- $query = where .Site.Home.Sections.ByTitle "Section" $menu_name -}}
|
|
{{- else if eq $order_by "title_desc" -}}
|
|
{{- $query = where .Site.Home.Sections.ByTitle.Reverse "Section" $menu_name -}}
|
|
{{- else -}}
|
|
{{- $query = where .Site.Home.Sections.ByWeight "Section" $menu_name -}}
|
|
{{- end -}}
|
|
|
|
{{- range $query -}}
|
|
{{ template "book-menu" dict "sect" . "current_node" $current_node "order_by" $order_by "is_root" $is_root }}
|
|
{{- end -}}
|
|
|
|
{{ else }}
|
|
{{/* Case where first section is a general page (e.g. book of books). */}}
|
|
|
|
<ul class="nav docs-sidenav">
|
|
<li><a href="{{.FirstSection.RelPermalink}}"><i class="fas fa-arrow-left pr-1"></i>{{.FirstSection.LinkTitle | emojify}}</a></li>
|
|
</ul>
|
|
|
|
{{ $first_node := $current_node }}
|
|
{{ if ne .Parent .FirstSection }}
|
|
{{ if ne .Parent.Parent .FirstSection }}
|
|
{{ $first_node = $current_node.Parent.Parent }}
|
|
{{else}}
|
|
{{ $first_node = $current_node.Parent }}
|
|
{{end}}
|
|
{{end}}
|
|
|
|
{{- if eq $order_by "title" -}}
|
|
{{- $query = $first_node.Pages.ByTitle -}}
|
|
{{- else if eq $order_by "title_desc" -}}
|
|
{{- $query = $first_node.Pages.ByTitle.Reverse -}}
|
|
{{- else -}}
|
|
{{- $query = $first_node.Pages.ByWeight -}}
|
|
{{- end -}}
|
|
{{ template "book-menu" dict "sect" $first_node "current_node" $current_node "order_by" $order_by "is_root" $is_root }}
|
|
{{end}}
|
|
{{end}}
|
|
</nav>
|