Hugo-theme-stack/layouts/partials/sidebar/left.html
Victor Lourme f919b8bd90
feat(sidebar): add support for external avatar (#53)
add [params.sidebar.avatar] section in config.toml, with 2 fields: local and src

Migration guide:
 - Copy the old value of `params.sidebar.avatar` to `param.sidebar.avatar.src`
 - Set params.sidebar.avatar.local = true

Co-authored-by: Jimmy Cai <jimmehcai@gmail.com>
2020-12-11 16:33:02 +01:00

50 lines
2.0 KiB
HTML

<aside class="sidebar left-sidebar sticky">
<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 class="site-info">
{{ with .Site.Params.sidebar.avatar }}
<figure class="site-avatar">
{{ 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 }}
{{ with $.Site.Params.sidebar.emoji }}
<span class="emoji">{{ . }}</span>
{{ end }}
</figure>
{{ end }}
<h1 class="site-name"><a href="{{ .Site.BaseURL }}">{{ .Site.Title }}</a></h1>
<h2 class="site-description">{{ .Site.Params.sidebar.subtitle }}</h2>
</header>
<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 | relURL }}'>
{{ if .Pre }}
{{ partial "helper/icon" .Pre }}
{{ end }}
<span>{{- .Name -}}</span>
</a>
</li>
{{ end }}
</ol>
</aside>