add social links to sidebar
This commit is contained in:
39
hugo.toml
39
hugo.toml
@ -7,13 +7,36 @@ title = 'My New Hugo Site'
|
|||||||
path = "github.com/gohugoio/hugo-mod-bootstrap-scss/v5"
|
path = "github.com/gohugoio/hugo-mod-bootstrap-scss/v5"
|
||||||
|
|
||||||
[[menu.main]]
|
[[menu.main]]
|
||||||
name = "首页"
|
name = "首页"
|
||||||
url = "/"
|
url = "/"
|
||||||
weight = 10
|
weight = 10
|
||||||
pre = "fa-solid fa-house"
|
pre = "fa-solid fa-house"
|
||||||
|
|
||||||
[[menu.main]]
|
[[menu.main]]
|
||||||
name = "关于"
|
name = "关于"
|
||||||
url = "/about/"
|
url = "/about/"
|
||||||
weight = 20
|
weight = 20
|
||||||
pre = "fa-solid fa-house"
|
pre = "fa-solid fa-house"
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
[[params.social]]
|
||||||
|
type = "github"
|
||||||
|
id = "yourusername" # 或直接使用 url = "https://github.com/yourusername"
|
||||||
|
icon = "fab fa-github"
|
||||||
|
|
||||||
|
[[params.social]]
|
||||||
|
type = "twitter"
|
||||||
|
id = "yourhandle"
|
||||||
|
icon = "fab fa-twitter"
|
||||||
|
|
||||||
|
[[params.social]]
|
||||||
|
type = "email"
|
||||||
|
id = "your.email@example.com" # 会被自动分割处理
|
||||||
|
icon = "fas fa-envelope"
|
||||||
|
|
||||||
|
[[params.social]]
|
||||||
|
type = "rss"
|
||||||
|
icon = "fas fa-rss"
|
||||||
|
noblank = true # 不在新窗口打开
|
||||||
|
|
@ -31,6 +31,48 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
|
|
||||||
|
<div class="sidebar-bottom d-flex flex-wrap align-items-center w-100">
|
||||||
|
{{ if not .Site.Params.themeMode }}
|
||||||
|
<button type="button" class="btn btn-link nav-link" aria-label="Switch Mode" id="mode-toggle">
|
||||||
|
<i class="fas fa-adjust"></i>
|
||||||
|
</button>
|
||||||
|
|
||||||
|
{{ if .Site.Params.social }}
|
||||||
|
<span class="icon-border"></span>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ range .Site.Params.social }}
|
||||||
|
{{ $url := "" }}
|
||||||
|
{{ $rel := "" }}
|
||||||
|
|
||||||
|
{{ if eq .type "github" }}
|
||||||
|
{{ $url = printf "https://github.com/%s" .id }}
|
||||||
|
{{ else if eq .type "twitter" }}
|
||||||
|
{{ $url = printf "https://twitter.com/%s" .id }}
|
||||||
|
{{ else if eq .type "email" }}
|
||||||
|
{{ $emailParts := split .id "@" }}
|
||||||
|
{{ $url = printf "javascript:location.href = 'mailto:' + ['%s','%s'].join('@')" (index $emailParts 0) (index $emailParts 1) }}
|
||||||
|
{{ else if eq .type "rss" }}
|
||||||
|
{{ $url = "index.xml" | relURL }}
|
||||||
|
{{ else }}
|
||||||
|
{{ $url = .url }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
|
{{ if $url }}
|
||||||
|
<a
|
||||||
|
href="{{ $url }}"
|
||||||
|
aria-label="{{ .type }}"
|
||||||
|
{{ if not .noblank }}target="_blank" rel="noopener noreferrer"{{ end }}
|
||||||
|
{{ if eq .type "mastodon" }}rel="me"{{ end }}
|
||||||
|
>
|
||||||
|
<i class="{{ .icon }}"></i>
|
||||||
|
</a>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
</div>
|
||||||
|
<!-- .sidebar-bottom -->
|
||||||
|
|
||||||
|
|
||||||
</aside>
|
</aside>
|
||||||
<!-- #sidebar -->
|
<!-- #sidebar -->
|
Reference in New Issue
Block a user