diff options
author | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-11-03 20:08:36 +0300 |
---|---|---|
committer | Alexander Neonxp Kiryukhin <i@neonxp.ru> | 2024-11-03 20:08:36 +0300 |
commit | 59c7d4567380d1a9c80e96eb958fdbdd512ce006 (patch) | |
tree | 65410cfc10dbc7d060ec23be110662d9b7f6b0e9 /themes/hugo-theme-stack/layouts/partials/sidebar |
новая жизнь блога
Diffstat (limited to 'themes/hugo-theme-stack/layouts/partials/sidebar')
-rw-r--r-- | themes/hugo-theme-stack/layouts/partials/sidebar/left.html | 103 | ||||
-rw-r--r-- | themes/hugo-theme-stack/layouts/partials/sidebar/right.html | 16 |
2 files changed, 119 insertions, 0 deletions
diff --git a/themes/hugo-theme-stack/layouts/partials/sidebar/left.html b/themes/hugo-theme-stack/layouts/partials/sidebar/left.html new file mode 100644 index 0000000..21e7d3e --- /dev/null +++ b/themes/hugo-theme-stack/layouts/partials/sidebar/left.html @@ -0,0 +1,103 @@ +<aside class="sidebar left-sidebar sticky {{ if .Site.Params.sidebar.compact }}compact{{ end }}"> + <button class="hamburger hamburger--spin" type="button" id="toggle-menu" aria-label="{{ T `toggleMenu` }}"> + <span class="hamburger-box"> + <span class="hamburger-inner"></span> + </span> + </button> + + <header> + {{ with .Site.Params.sidebar.avatar }} + {{ if (default true .enabled) }} + <figure class="site-avatar"> + <a href="{{ .Site.BaseURL | relLangURL }}"> + {{ if not .local }} + <img src="{{ .src }}" width="300" height="300" class="site-logo" loading="lazy" alt="Avatar"> + {{ else }} + {{ $avatar := resources.Get (.src) }} + + {{ if $avatar }} + {{ $avatarResized := $avatar.Resize "300x" }} + <img src="{{ $avatarResized.RelPermalink }}" width="{{ $avatarResized.Width }}" + height="{{ $avatarResized.Height }}" class="site-logo" loading="lazy" alt="Avatar"> + {{ else }} + {{ errorf "Failed loading avatar from %q" . }} + {{ end }} + {{ end }} + </a> + {{ with $.Site.Params.sidebar.emoji }} + <span class="emoji">{{ . }}</span> + {{ end }} + </figure> + {{ end }} + {{ end }} + + <div class="site-meta"> + <h1 class="site-name"><a href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Title }}</a></h1> + <h2 class="site-description">{{ .Site.Params.sidebar.subtitle }}</h2> + </div> + </header> + + {{- with .Site.Menus.social -}} + <ol class="menu-social"> + {{ range . }} + <li> + <a + href='{{ .URL }}' + {{ if eq (default true .Params.newTab) true }}target="_blank"{{ end }} + {{ with .Name }}title="{{ . }}"{{ end }} + rel="me" + > + {{ $icon := default "link" .Params.Icon }} + {{ with $icon }} + {{ partial "helper/icon" . }} + {{ end }} + </a> + </li> + {{ end }} + </ol> + {{- end -}} + + <ol class="menu" id="main-menu"> + {{ $currentPage := . }} + {{ range .Site.Menus.main }} + {{ $active := or (eq $currentPage.Title .Name) (or ($currentPage.HasMenuCurrent "main" .) ($currentPage.IsMenuCurrent "main" .)) }} + <li {{ if $active }} class='current' {{ end }}> + <a href='{{ .URL }}' {{ if eq .Params.newTab true }}target="_blank"{{ end }}> + {{ $icon := default .Pre .Params.Icon }} + {{ if .Pre }} + {{ warnf "Menu item [%s] is using [pre] field to set icon, please use [params.icon] instead.\nMore information: https://stack.jimmycai.com/config/menu" .URL }} + {{ end }} + {{ with $icon }} + {{ partial "helper/icon" . }} + {{ end }} + <span>{{- .Name -}}</span> + </a> + </li> + {{ end }} + <li class="menu-bottom-section"> + <ol class="menu"> + {{- $currentLanguageCode := .Language.Lang -}} + {{ if ( compare.Gt .Site.Home.AllTranslations.Len 1 ) }} + {{ with .Site.Home.AllTranslations }} + <li id="i18n-switch"> + {{ partial "helper/icon" "language" }} + <select name="language" title="language" onchange="window.location.href = this.selectedOptions[0].value"> + {{ range . }} + <option value="{{ .Permalink }}" {{ if eq .Language.Lang $currentLanguageCode }}selected{{ end }}>{{ .Language.LanguageName }}</option> + {{ end }} + </select> + </li> + {{ end }} + {{ end }} + + {{ if (default false .Site.Params.colorScheme.toggle) }} + <li id="dark-mode-toggle"> + {{ partial "helper/icon" "toggle-left" }} + {{ partial "helper/icon" "toggle-right" }} + <span>{{ T "darkMode" }}</span> + </li> + {{ end }} + </ol> + </li> + </ol> +</aside> diff --git a/themes/hugo-theme-stack/layouts/partials/sidebar/right.html b/themes/hugo-theme-stack/layouts/partials/sidebar/right.html new file mode 100644 index 0000000..6333f10 --- /dev/null +++ b/themes/hugo-theme-stack/layouts/partials/sidebar/right.html @@ -0,0 +1,16 @@ +{{- $scope := default "homepage" .Scope -}} +{{- $context := .Context -}} +{{- with (index .Context.Site.Params.widgets $scope) -}} + <aside class="sidebar right-sidebar sticky"> + {{ range $widget := . }} + {{ if templates.Exists (printf "partials/widget/%s.html" .type) }} + <!-- Ensure that the `params` is not nil --> + {{- $params := default dict .params -}} + + {{ partial (printf "widget/%s" .type) (dict "Context" $context "Params" $params) }} + {{ else }} + {{ warnf "Widget %s not found" .type }} + {{ end }} + {{ end }} + </aside> +{{ end }}
\ No newline at end of file |