left.html 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <aside class="sidebar left-sidebar sticky {{ if .Site.Params.sidebar.compact }}compact{{ end }}">
  2. <button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="{{ T `toggleMenu` }}">
  3. <span class="hamburger-box">
  4. <span class="hamburger-inner"></span>
  5. </span>
  6. </button>
  7. <header>
  8. {{ with .Site.Params.sidebar.avatar }}
  9. {{ if (default true .enabled) }}
  10. <figure class="site-avatar">
  11. <a href="{{ .Site.BaseURL | relLangURL }}">
  12. {{ if not .local }}
  13. <img src="{{ .src }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar">
  14. {{ else }}
  15. {{ $avatar := resources.Get (.src) }}
  16. {{ if $avatar }}
  17. {{ $avatarResized := $avatar.Resize "300x" }}
  18. <img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}"
  19. height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar">
  20. {{ else }}
  21. {{ errorf "Failed loading avatar from %q" . }}
  22. {{ end }}
  23. {{ end }}
  24. </a>
  25. {{ with $.Site.Params.sidebar.emoji }}
  26. <span class="emoji">{{ . }}</span>
  27. {{ end }}
  28. </figure>
  29. {{ end }}
  30. {{ end }}
  31. <div class="site-meta">
  32. <h1 class="site-name"><a href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Title }}</a></h1>
  33. <h2 class="site-description">{{ .Site.Params.sidebar.subtitle }}</h2>
  34. </div>
  35. </header>
  36. {{- with .Site.Menus.social -}}
  37. <ol class="social-menu">
  38. {{ range . }}
  39. <li>
  40. <a
  41. href='{{ .URL }}'
  42. {{ if eq (default true .Params.newTab) true }}target="_blank"{{ end }}
  43. {{ with .Name }}title="{{ . }}"{{ end }}
  44. >
  45. {{ $icon := default "link" .Params.Icon }}
  46. {{ with $icon }}
  47. {{ partial "helper/icon" . }}
  48. {{ end }}
  49. </a>
  50. </li>
  51. {{ end }}
  52. </ol>
  53. {{- end -}}
  54. <ol class="menu" id="main-menu">
  55. {{ $currentPage := . }}
  56. {{ range .Site.Menus.main }}
  57. {{ $active := or (eq $currentPage.Title .Name) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }}
  58. <li {{ if $active }} class='current' {{ end }}>
  59. <a href='{{ .URL | relLangURL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}>
  60. {{ $icon := default .Pre .Params.Icon }}
  61. {{ if .Pre }}
  62. {{ warnf "Menu item [%s] is using [pre] field to set icon, please use [params.icon] instead.\nMore information: https://docs.stack.jimmycai.com/configuration/custom-menu.html" .URL }}
  63. {{ end }}
  64. {{ with $icon }}
  65. {{ partial "helper/icon" . }}
  66. {{ end }}
  67. <span>{{- .Name -}}</span>
  68. </a>
  69. </li>
  70. {{ end }}
  71. <div class="menu-bottom-section">
  72. {{- $currentLanguageCode := .Language.Lang -}}
  73. {{ with .Site.Home.AllTranslations }}
  74. <li id="i18n-switch">
  75. {{ partial "helper/icon" "language" }}
  76. <select name="language" onchange="window.location.href = this.selectedOptions[0].value">
  77. {{ range . }}
  78. <option value="{{ .Permalink }}" {{ if eq .Language.Lang $currentLanguageCode }}selected{{ end }}>{{ .Language.LanguageName }}</option>
  79. {{ end }}
  80. </select>
  81. </li>
  82. {{ end }}
  83. {{ if (default false .Site.Params.colorScheme.toggle) }}
  84. <li id="dark-mode-toggle">
  85. {{ partial "helper/icon" "toggle-left" }}
  86. {{ partial "helper/icon" "toggle-right" }}
  87. <span>{{ T "darkMode" }}</span>
  88. </li>
  89. {{ end }}
  90. </div>
  91. </ol>
  92. </aside>