Skip to content

Commit 661e59b

Browse files
authored
feat: social menu (#401)
1 parent 7c59ac7 commit 661e59b

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

assets/icons/brand-github.svg

Lines changed: 6 additions & 0 deletions
Loading

assets/icons/brand-twitter.svg

Lines changed: 6 additions & 0 deletions
Loading

assets/scss/partials/menu.scss

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,18 @@
201201
}
202202
}
203203
}
204+
205+
.social-menu {
206+
list-style: none;
207+
padding: 0%;
208+
display: flex;
209+
flex-direction: row;
210+
gap: 10px;
211+
212+
svg {
213+
width: 24px;
214+
height: 24px;
215+
stroke: var(--body-text-color);
216+
stroke-width: 1.33;
217+
}
218+
}

exampleSite/config.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,19 @@ menu:
178178
### For demonstration purpose, the home link will be open in a new tab
179179
newTab: true
180180
icon: home
181+
182+
social:
183+
- identifier: github
184+
name: GitHub
185+
url: https://github.com/CaiJimmy/hugo-theme-stack
186+
params:
187+
icon: brand-github
188+
189+
- identifier: twitter
190+
name: Twitter
191+
url: https://twitter.com
192+
params:
193+
icon: brand-twitter
181194

182195
related:
183196
includeNewer: true

layouts/partials/sidebar/left.html

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,28 @@
2929
</figure>
3030
{{ end }}
3131
{{ end }}
32+
3233
<h1 class="site-name"><a href="{{ .Site.BaseURL | relLangURL }}">{{ .Site.Title }}</a></h1>
3334
<h2 class="site-description">{{ .Site.Params.sidebar.subtitle }}</h2>
35+
36+
{{- with .Site.Menus.social -}}
37+
<ol class="social-menu">
38+
{{ range . }}
39+
<li>
40+
<a
41+
href='{{ .URL | relLangURL }}'
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 -}}
3454
</header>
3555

3656
<ol class="menu" id="main-menu">

0 commit comments

Comments
 (0)