menu.html 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <nav id="sidebar" class="{{if $.Site.Params.showVisitedLinks }}showVisitedLinks{{end}}">
  2. {{ $currentNode := . }}
  3. {{ $showvisitedlinks := .Site.Params.showVisitedLinks }}
  4. <div id="header-wrapper">
  5. <div id="header">
  6. {{ partial "logo.html" . }}
  7. </div>
  8. {{if not .Site.Params.disableSearch}}
  9. {{ partial "search.html" . }}
  10. {{end}}
  11. </div>
  12. <div class="highlightable">
  13. <ul class="topics">
  14. {{if eq .Site.Params.ordersectionsby "title"}}
  15. {{range .Site.Home.Sections.ByTitle}}
  16. {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks}}
  17. {{end}}
  18. {{else}}
  19. {{range .Site.Home.Sections.ByWeight}}
  20. {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks}}
  21. {{end}}
  22. {{end}}
  23. </ul>
  24. {{ $disableShortcutsTitle := .Site.Params.DisableShortcutsTitle}}
  25. {{with .Site.Menus.shortcuts}}
  26. <section id="shortcuts">
  27. <h3>{{ if not $disableShortcutsTitle}}{{ T "Shortcuts-Title"}}{{ end }}</h3>
  28. <ul>
  29. {{ range sort . "Weight"}}
  30. <li>
  31. {{.Pre}}<a class="padding" href="{{.URL | absLangURL }}">{{safeHTML .Name}}</a>{{.Post}}
  32. </li>
  33. {{end}}
  34. </ul>
  35. </section>
  36. {{end}}
  37. {{ if or .Site.IsMultiLingual $showvisitedlinks }}
  38. <section id="prefooter">
  39. <hr/>
  40. <ul>
  41. {{ if and .Site.IsMultiLingual (not .Site.Params.DisableLanguageSwitchingButton)}}
  42. <li>
  43. <a class="padding">
  44. <i class="fas fa-language fa-fw"></i>
  45. <div class="select-style">
  46. <select id="select-language" onchange="location = this.value;">
  47. {{ $siteLanguages := .Site.Languages}}
  48. {{ $pageLang := .Page.Lang}}
  49. {{ range .Page.AllTranslations }}
  50. {{ $translation := .}}
  51. {{ range $siteLanguages }}
  52. {{ if eq $translation.Lang .Lang }}
  53. {{ $selected := false }}
  54. {{ if eq $pageLang .Lang}}
  55. <option id="{{ $translation.Language }}" value="{{ $translation.URL }}" selected>{{ .LanguageName }}</option>
  56. {{ else }}
  57. <option id="{{ $translation.Language }}" value="{{ $translation.URL }}">{{ .LanguageName }}</option>
  58. {{ end }}
  59. {{ end }}
  60. {{ end }}
  61. {{ end }}
  62. </select>
  63. <svg version="1.1" id="Capa_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
  64. width="255px" height="255px" viewBox="0 0 255 255" style="enable-background:new 0 0 255 255;" xml:space="preserve">
  65. <g>
  66. <g id="arrow-drop-down">
  67. <polygon points="0,63.75 127.5,191.25 255,63.75 " />
  68. </g>
  69. </g>
  70. </svg>
  71. </div>
  72. </a>
  73. </li>
  74. {{end}}
  75. {{ if $showvisitedlinks}}
  76. <li><a class="padding" href="#" data-clear-history-toggle=""><i class="fas fa-history fa-fw"></i> {{T "Clear-History"}}</a></li>
  77. {{ end }}
  78. </ul>
  79. </section>
  80. {{ end }}
  81. <section id="footer">
  82. {{ partial "menu-footer.html" . }}
  83. </section>
  84. </div>
  85. </nav>
  86. <!-- templates -->
  87. {{ define "section-tree-nav" }}
  88. {{ $showvisitedlinks := .showvisitedlinks }}
  89. {{ $currentNode := .currentnode }}
  90. {{with .sect}}
  91. {{if .IsSection}}
  92. {{safeHTML .Params.head}}
  93. <li data-nav-id="{{.URL}}" title="{{.Title}}" class="dd-item
  94. {{if .IsAncestor $currentNode }}parent{{end}}
  95. {{if eq .UniqueID $currentNode.UniqueID}}active{{end}}
  96. {{if .Params.alwaysopen}}parent{{end}}
  97. ">
  98. <a href="{{.RelPermalink}}">
  99. {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
  100. {{ if $showvisitedlinks}}
  101. <i class="fas fa-check read-icon"></i>
  102. {{ end }}
  103. </a>
  104. {{ $numberOfPages := (add (len .Pages) (len .Sections)) }}
  105. {{ if ne $numberOfPages 0 }}
  106. <ul>
  107. {{ $currentNode.Scratch.Set "pages" .Pages }}
  108. {{ if .Sections}}
  109. {{ $currentNode.Scratch.Set "pages" (.Pages | union .Sections) }}
  110. {{end}}
  111. {{ $pages := ($currentNode.Scratch.Get "pages") }}
  112. {{if eq .Site.Params.ordersectionsby "title"}}
  113. {{ range $pages.ByTitle }}
  114. {{ if and .Params.hidden (not $.showhidden) }}
  115. {{else}}
  116. {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }}
  117. {{end}}
  118. {{ end }}
  119. {{else}}
  120. {{ range $pages.ByWeight }}
  121. {{ if and .Params.hidden (not $.showhidden) }}
  122. {{else}}
  123. {{ template "section-tree-nav" dict "sect" . "currentnode" $currentNode "showvisitedlinks" $showvisitedlinks }}
  124. {{end}}
  125. {{ end }}
  126. {{end}}
  127. </ul>
  128. {{ end }}
  129. </li>
  130. {{else}}
  131. {{ if not .Params.Hidden }}
  132. <li data-nav-id="{{.URL}}" title="{{.Title}}" class="dd-item {{if eq .UniqueID $currentNode.UniqueID}}active{{end}}">
  133. <a href="{{ .RelPermalink}}">
  134. {{safeHTML .Params.Pre}}{{or .Params.menuTitle .LinkTitle .Title}}{{safeHTML .Params.Post}}
  135. {{ if $showvisitedlinks}}<i class="fas fa-check read-icon"></i>{{end}}
  136. </a>
  137. </li>
  138. {{ end }}
  139. {{end}}
  140. {{ end }}
  141. {{ end }}