Use URI templates for social network links (#586)

This commit is contained in:
cketti 2020-03-15 22:41:12 +01:00 committed by GitHub
parent 7715136c82
commit f2ef9f238d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 24 deletions

View File

@ -2,91 +2,90 @@
# Use the same key you added in _config.yml -> social-network-links. # Use the same key you added in _config.yml -> social-network-links.
# In addition to that you need to specify the following properties: # In addition to that you need to specify the following properties:
# name: Specify a user-friendly name that will be used as a link title # name: Specify a user-friendly name that will be used as a link title
# baseURL: Define a base URL which will be combined with the value of # urlTemplate: Define a URL template. The variable {value} will be replaced
# site.social-network-links.<key> # with the value of site.social-network-links.<key>
# icon: Specify a valid fontawesome icon class # icon: Specify a valid fontawesome icon class
facebook: facebook:
name: "Facebook" name: "Facebook"
baseURL: "https://www.facebook.com/" urlTemplate: "https://www.facebook.com/{value}"
icon: "fa-facebook" icon: "fa-facebook"
github: github:
name: "GitHub" name: "GitHub"
baseURL: "https://github.com/" urlTemplate: "https://github.com/{value}"
icon: "fa-github" icon: "fa-github"
twitter: twitter:
name: "Twitter" name: "Twitter"
baseURL: "https://twitter.com/" urlTemplate: "https://twitter.com/{value}"
icon: "fa-twitter" icon: "fa-twitter"
reddit: reddit:
name: "Reddit" name: "Reddit"
baseURL: "https://reddit.com/u/" urlTemplate: "https://reddit.com/u/{value}"
icon: "fa-reddit" icon: "fa-reddit"
email: email:
name: "Email me" name: "Email me"
baseURL: "mailto:" urlTemplate: "mailto:{value}"
icon: "fa-envelope" icon: "fa-envelope"
linkedin: linkedin:
name: "LinkedIn" name: "LinkedIn"
baseURL: "https://linkedin.com/in/" urlTemplate: "https://linkedin.com/in/{value}"
icon: "fa-linkedin" icon: "fa-linkedin"
xing: xing:
name: "Xing" name: "Xing"
baseURL: "https://www.xing.com/profile/" urlTemplate: "https://www.xing.com/profile/{value}"
icon: "fa-xing" icon: "fa-xing"
stackoverflow: stackoverflow:
name: "StackOverflow" name: "StackOverflow"
baseURL: "https://stackoverflow.com/users/" urlTemplate: "https://stackoverflow.com/users/{value}"
icon: "fa-stack-overflow" icon: "fa-stack-overflow"
snapchat: snapchat:
name: "Snapchat" name: "Snapchat"
baseURL: "https://www.snapchat.com/add/" urlTemplate: "https://www.snapchat.com/add/{value}"
icon: "fa-snapchat-ghost" icon: "fa-snapchat-ghost"
instagram: instagram:
name: "Instagram" name: "Instagram"
baseURL: "https://www.instagram.com/" urlTemplate: "https://www.instagram.com/{value}"
icon: "fa-instagram" icon: "fa-instagram"
youtube: youtube:
name: "YouTube" name: "YouTube"
baseURL: "https://www.youtube.com/" urlTemplate: "https://www.youtube.com/{value}"
icon: "fa-youtube" icon: "fa-youtube"
spotify: spotify:
name: "Spotify" name: "Spotify"
baseURL: "https://open.spotify.com/user/" urlTemplate: "https://open.spotify.com/user/{value}"
icon: "fa-spotify" icon: "fa-spotify"
telephone: telephone:
name: "Phone" name: "Phone"
baseURL: "tel:" urlTemplate: "tel:{value}"
icon: "fa-phone" icon: "fa-phone"
rss: rss:
name: "RSS" name: "RSS"
baseURL: "{{ '/feed.xml' | relative_url }}"
icon: "fa-rss" icon: "fa-rss"
steam: steam:
name: "Steam" name: "Steam"
baseURL: "https://steamcommunity.com/id/" urlTemplate: "https://steamcommunity.com/id/{value}"
icon: "fa-steam" icon: "fa-steam"
twitch: twitch:
name: "Twitch" name: "Twitch"
baseURL: "https://www.twitch.tv/" urlTemplate: "https://www.twitch.tv/{value}"
icon: "fa-twitch" icon: "fa-twitch"
yelp: yelp:
name: "Yelp" name: "Yelp"
baseURL: "https://{{ site.author.yelp }}.yelp.com" urlTemplate: "https://{value}.yelp.com"
icon: "fa-yelp" icon: "fa-yelp"

View File

@ -6,14 +6,15 @@
{%- for link in site.social-network-links -%} {%- for link in site.social-network-links -%}
{%- assign curkey = link[0] -%} {%- assign curkey = link[0] -%}
{%- assign element = site.data.SocialNetworks[curkey] -%} {%- assign element = site.data.SocialNetworks[curkey] -%}
<li>
{%- if curkey == 'rss' -%} {%- if curkey == 'rss' -%}
<a href="{{ '/feed.xml' | relative_url }}" title="{{ element.name }}"> {%- capture url -%}{{ '/feed.xml' | relative_url }}{%- endcapture -%}
{%- elsif curkey == 'yelp' -%}
<a href="https://{{ site.social-network-links[curkey] }}.yelp.com" title="{{ element.name }}">
{%- else -%} {%- else -%}
<a href="{{element.baseURL}}{{ site.social-network-links[curkey] }}" title="{{ element.name }}"> {%- assign value = site.social-network-links[curkey] -%}
{%- assign placeholder = "{value}" -%}
{%- capture url -%}{{ element.urlTemplate | replace: placeholder, value }}{%- endcapture -%}
{%- endif -%} {%- endif -%}
<li>
<a href="{{ url }}" title="{{ element.name }}">
<span class="fa-stack fa-lg" aria-hidden="true"> <span class="fa-stack fa-lg" aria-hidden="true">
<i class="fa fa-circle fa-stack-2x"></i> <i class="fa fa-circle fa-stack-2x"></i>
<i class="fa {{ element.icon }} fa-stack-1x fa-inverse"></i> <i class="fa {{ element.icon }} fa-stack-1x fa-inverse"></i>