Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/fncnt/vncnt-hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfncnt <github@vncnt.eu>2021-05-20 13:33:12 +0300
committerfncnt <github@vncnt.eu>2021-05-20 13:33:12 +0300
commit4c1d20a49cbc8c463d64fcba747433b0bae1df8b (patch)
treec949feee7ad92e44735b476581ff0d20f23d4e22
parent5e7769ea645be11dc4075908c71951920d8f4402 (diff)
Better handling of contact link definitions
-rw-r--r--README.md7
-rw-r--r--config.toml24
-rw-r--r--exampleSite/config.toml24
-rw-r--r--layouts/partials/body.html13
4 files changed, 52 insertions, 16 deletions
diff --git a/README.md b/README.md
index 686572d..55fa3ce 100644
--- a/README.md
+++ b/README.md
@@ -28,12 +28,9 @@ linkedin = "https://www.linkedin.com/in/jdoe"
```
Please note that the key must correspond to a [fontawesome brands icon](https://fontawesome.com/icons?d=gallery&s=brands).
Also, regardless of the key order in your `config.toml` file, the links will be ordered lexicographically due to the usage of [`range`](https://golang.org/pkg/text/template/#hdr-Actions).
-However, those are trade-offs I'm willing to accept for simplicity.
-You may specify another `fontawesome` icon and class like this:
-```
-mountain = [ "https://local-hiking.club", "fas" ]
-```
+However, you may specify contact links more verbosely, as documented in [`config.toml`](config.toml).
+This allows to use other fontawesome styles and manually sort contact links.
## Third-party Components
diff --git a/config.toml b/config.toml
index 710ca1a..932ed0b 100644
--- a/config.toml
+++ b/config.toml
@@ -21,7 +21,9 @@ title = "John Doe · Landing Page"
[params]
author = "John Doe"
- email = "john.doe@example.com"
+ # email does still work but is deprecated.
+ # use [params.contact.email] instead.
+ #email = "john.doe@example.com"
description = "Landing Page"
bio = "First Row. \nSecond Row."
avatar = "img/avatar.jpg"
@@ -32,5 +34,21 @@ title = "John Doe · Landing Page"
github = "https://github.com/jdoe"
instagram = "https://instagram.com/jdoe"
twitter = "https://twitter.com/jdoe"
- ello = ""
- hiking = [ "https://local-hiking.club", "fas" ]
+
+ # You may use (inline) tables for more versatility
+ # This allows sorting and even more icons.
+ # Just make sure not to mix key-value pairs, inline tables and tables,
+ # although keeping keeping this order is ok.
+ # See https://toml.io/en/v1.0.0 for details
+ 0 = { name = "ello", icon = "ello", style = "fab", link = "" } # empty links are relative to site root
+ [params.contact.1] # key names are sorted lexicographically
+ name = "hiking club" # may be omitted. defaults to key name
+ icon = "hiking" # may be omitted. defaults to key name
+ style = "fas" # may be omitted. default = "fas"
+ link = "https://local-hiking.club"
+ [params.contact.email]
+ name = "email" # may be omitted. defaults to key name
+ icon = "envelope" # may be omitted. defaults to key name
+ style = "fas" # may be omitted. default = "fas"
+ link = "mailto:john.doe@example.com"
+
diff --git a/exampleSite/config.toml b/exampleSite/config.toml
index 710ca1a..ff6260d 100644
--- a/exampleSite/config.toml
+++ b/exampleSite/config.toml
@@ -21,7 +21,9 @@ title = "John Doe · Landing Page"
[params]
author = "John Doe"
- email = "john.doe@example.com"
+ # email does still work but is deprecated.
+ # use [params.contact.email] instead.
+ #email = "john.doe@example.com"
description = "Landing Page"
bio = "First Row. \nSecond Row."
avatar = "img/avatar.jpg"
@@ -32,5 +34,21 @@ title = "John Doe · Landing Page"
github = "https://github.com/jdoe"
instagram = "https://instagram.com/jdoe"
twitter = "https://twitter.com/jdoe"
- ello = ""
- hiking = [ "https://local-hiking.club", "fas" ]
+
+ # You may use (inline) tables for more versatility
+ # This allows sorting and even more icons.
+ # Just make sure not to mix key-value pairs, inline tables and tables,
+ # although keeping keeping this order is ok.
+ # See https://toml.io/en/v1.0.0 for details
+ 0 = { name = "ello", icon = "ello", style = "fab", link = "" } # empty links are relative to site root
+ [params.contact.1] # key names are sorted lexicographically
+ name = "hiking club" # may be omitted. defaults to key name
+ icon = "hiking" # may be omitted. defaults to key name
+ style = "fas" # may be omitted. default = "fas"
+ link = "https://local-hiking.club"
+ [params.contact.email]
+ name = "email" # may be omitted. defaults to key name
+ icon = "envelope" # may be omitted. defaults to key name
+ style = "fas" # may be omitted. default = "fas"
+ link = "mailto:john.doe@example.com"
+
diff --git a/layouts/partials/body.html b/layouts/partials/body.html
index 03ffb06..15141c1 100644
--- a/layouts/partials/body.html
+++ b/layouts/partials/body.html
@@ -16,12 +16,15 @@
{{ with .Site.Params.email }}<a class="icon" href="mailto:{{ . }}" target="_blank" rel="noopener me">
<i class="fas fa-envelope" title="email" aria-label="Send email."></i>
</a>{{ end }}
- {{ range $contact_key, $contact_link := .Site.Params.contact }}
- {{ if in (slice "fab" "fas" "far" "fal" "fad") (index $contact_link 1) }}
- <a class="icon" href="{{ index $contact_link 0 }}" target="_blank" rel="noopener me">
- <i class="{{ index $contact_link 1 }} fa-{{ $contact_key }}" title="{{ $contact_key }}" aria-label="Go to {{ $contact_key }}."></i>
+ {{ range $contact_key, $contact := .Site.Params.contact }}
+ {{ if reflect.IsMap $contact }}
+ {{ $style := default "fas" (index $contact "style") }}
+ {{ $icon := default $contact_key (index $contact "icon") }}
+ {{ $label := default $contact_key (index $contact "name") }}
+ <a class="icon" href="{{ index $contact "link" }}" target="_blank" rel="noopener me">
+ <i class="{{ $style }} fa-{{ $icon }}" title="{{ $label }}" aria-label="Go to {{ $label }}."></i>
{{ else }}
- <a class="icon" href="{{ $contact_link }}" target="_blank" rel="noopener me">
+ <a class="icon" href="{{ $contact }}" target="_blank" rel="noopener me">
<i class="fab fa-{{ $contact_key }}" title="{{ $contact_key }}" aria-label="Go to {{ $contact_key }}."></i>
{{ end }}
</a>{{ end }}