diff options
author | Simon <gevhaz@tutanota.com> | 2020-06-04 01:28:12 +0300 |
---|---|---|
committer | Simon <gevhaz@tutanota.com> | 2020-06-04 01:28:12 +0300 |
commit | be6d852d334b51987501ab6e7c54f73293ae9aa8 (patch) | |
tree | 187e68fe2fd1070807738ccd940b2d037ba0b2db | |
parent | d0f9af62892792e19e0f0a795af1042ed41f5004 (diff) |
Sort social links by weight and show name of site instead of username
-rw-r--r-- | data/notrack/social.yaml | 2 | ||||
-rw-r--r-- | layouts/shortcodes/contact-box.html | 16 | ||||
-rw-r--r-- | layouts/shortcodes/social.html | 16 | ||||
-rw-r--r-- | static/css/styles.css | 2 | ||||
-rw-r--r-- | static/css/styles.scss | 3 |
5 files changed, 34 insertions, 5 deletions
diff --git a/data/notrack/social.yaml b/data/notrack/social.yaml index f0940dd..67a694b 100644 --- a/data/notrack/social.yaml +++ b/data/notrack/social.yaml @@ -34,7 +34,7 @@ instagram: facebook: weight: 5 prefix: https://facebook.com/ - title: facebook + title: Facebook icon: class: fab fa-facebook fa-fw diff --git a/layouts/shortcodes/contact-box.html b/layouts/shortcodes/contact-box.html index 1738466..000c9f8 100644 --- a/layouts/shortcodes/contact-box.html +++ b/layouts/shortcodes/contact-box.html @@ -10,10 +10,22 @@ {{ with $.Site.Params.social }} <div class="contactbox contactlinks"> <ul> - {{ range $website, $user := . }} + {{- $socialArray := slice -}} + {{ range $website, $user := $.Site.Params.social }} + {{- $social := $website | lower | index $socialMap | default dict -}} + {{- $social := dict "user" $user | merge $social -}} + {{- $data := index $socialMap $website -}} - <li><a href="{{- $data.prefix -}}{{ $user }}"><i class="{{- $data.icon.class -}}"></i>{{ $data.title }}</a></li> + + {{- $socialArray = $socialArray | append $social -}} {{ end }} + {{ range sort $socialArray "weight" -}} + {{- if .prefix -}} + <li><a href="{{- .prefix -}}{{ .user }}"><i class="{{- .icon.class -}}"></i>{{ .title }}</a></li> + {{- else if .template -}} + <li><a href="{{- printf .template .user -}}"><i class="{{- .icon.class -}}"></i>{{ .title }}</a></li> + {{- end -}} + {{- end -}} </ul> </div> {{ end }} diff --git a/layouts/shortcodes/social.html b/layouts/shortcodes/social.html index 0278093..fef88ec 100644 --- a/layouts/shortcodes/social.html +++ b/layouts/shortcodes/social.html @@ -3,10 +3,22 @@ {{ with $.Site.Params.social }} <div class="social"> <ul> - {{ range $website, $user := . }} + {{- $socialArray := slice -}} + {{ range $website, $user := $.Site.Params.social }} + {{- $social := $website | lower | index $socialMap | default dict -}} + {{- $social := dict "user" $user | merge $social -}} + {{- $data := index $socialMap $website -}} - <li><a href="{{- $data.prefix -}}{{ $user }}"><i class="{{- $data.icon.class -}}"></i><span>{{ $user }}</span></a></li> + + {{- $socialArray = $socialArray | append $social -}} {{ end }} + {{ range sort $socialArray "weight" -}} + {{- if .prefix -}} + <li><a href="{{- .prefix -}}{{ .user }}"><i class="{{- .icon.class -}}"></i>{{ .title }}</a></li> + {{- else if .template -}} + <li><a href="{{- printf .template .user -}}"><i class="{{- .icon.class -}}"></i>{{ .title }}</a></li> + {{- end -}} + {{- end -}} </ul> </div> {{ end }} diff --git a/static/css/styles.css b/static/css/styles.css index ba2a2d4..68f6e2c 100644 --- a/static/css/styles.css +++ b/static/css/styles.css @@ -377,6 +377,8 @@ em.taxonomy-emph { .contactbox.contactlinks { margin-bottom: 0.4em; } + .contactbox.contactlinks a { + white-space: nowrap; } .social { display: flex; diff --git a/static/css/styles.scss b/static/css/styles.scss index 655eed7..a645e98 100644 --- a/static/css/styles.scss +++ b/static/css/styles.scss @@ -517,6 +517,9 @@ em.taxonomy-emph { .contactbox.contactlinks { margin-bottom: 0.4em; + a { + white-space: nowrap; + } } .social { |