mirror of
https://github.com/tiennm99/HugoBlox-kit.git
synced 2026-10-12 20:15:25 +00:00
feat: add option to show superuser social links in header (#2010)
To use, add label and display options to superuser's `social` links: ``` social: - icon: twitter icon_pack: fab link: https://twitter.com/<USERNAME> label: Follow me on Twitter display: header: true ```
This commit is contained in:
1 parent
e47738df59
commit
e99eb34795
2 files changed
+50
No files matched your search
@@ -0,0 +1,37 @@
|
||||
{{/* Function to return a linked social icon as a map from an iteration of an author's `social` data. */}}
|
||||
|
||||
{{ $scr := newScratch }}
|
||||
|
||||
{{/* Get icon name. */}}
|
||||
{{ $scr.SetInMap "social_link" "icon" .icon }}
|
||||
|
||||
{{/* Get icon pack (default to Font Awesome's Solid pack). */}}
|
||||
{{ $pack := or .icon_pack "fas" }}
|
||||
{{ $scr.SetInMap "social_link" "icon_pack" $pack }}
|
||||
|
||||
{{/* Derive Font Awesome class name prefix. */}}
|
||||
{{ $pack_prefix := $pack }}
|
||||
{{ if in (slice "fab" "fas" "far" "fal") $pack }}
|
||||
{{ $pack_prefix = "fa" }}
|
||||
{{ end }}
|
||||
{{ $scr.SetInMap "social_link" "pack_prefix" $pack_prefix }}
|
||||
|
||||
{{/* Get tooltip label (default to none). */}}
|
||||
{{ $scr.SetInMap "social_link" "tooltip" (.label | default "") }}
|
||||
|
||||
{{/* Get screen reader label (default to icon name). */}}
|
||||
{{ $scr.SetInMap "social_link" "aria_label" (.label | default .icon) }}
|
||||
|
||||
{{/* Get external link or relative internal link. */}}
|
||||
{{ $link := .link }}
|
||||
{{ $target := "" }}
|
||||
{{ $scheme := (urls.Parse $link).Scheme }}
|
||||
{{ if not $scheme }}
|
||||
{{ $link = .link | relLangURL }}
|
||||
{{ else if in (slice "http" "https") $scheme }}
|
||||
{{ $target = "target=\"_blank\" rel=\"noopener\"" }}
|
||||
{{ end }}
|
||||
{{ $scr.SetInMap "social_link" "link" $link }}
|
||||
{{ $scr.SetInMap "social_link" "target" $target }}
|
||||
|
||||
{{ return $scr.Get "social_link" }}
|
||||
@@ -139,6 +139,19 @@
|
||||
</div><!-- /.navbar-collapse -->
|
||||
|
||||
<ul class="nav-icons navbar-nav flex-row ml-auto d-flex pl-md-2">
|
||||
|
||||
{{/* Display any social links that the superuser chose to display in the header. */}}
|
||||
{{ range where (where (where site.Pages "Section" "authors") ".Params.superuser" true) ".Params.social" "!=" nil }}
|
||||
{{ range where .Params.social ".display.header" true }}
|
||||
{{ $social_link := partial "functions/get_social_link" . }}
|
||||
<li class="nav-item d-none d-lg-inline-flex">
|
||||
<a class="nav-link" href="{{ $social_link.link | safeURL }}"{{ with $social_link.tooltip }} data-toggle="tooltip" data-placement="bottom" title="{{.}}"{{ end }} {{ $social_link.target | safeHTMLAttr }} aria-label="{{ $social_link.aria_label }}">
|
||||
<i class="{{ $social_link.icon_pack }} {{ $social_link.pack_prefix }}-{{ $social_link.icon }}" aria-hidden="true"></i>
|
||||
</a>
|
||||
</li>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
|
||||
{{ $show_search := site.Params.main_menu.show_search | default true }}
|
||||
{{ if and site.Params.search.engine $show_search }}
|
||||
<li class="nav-item">
|
||||
|
||||
Reference in new issue
Block a user