Feature: make contact options configurable (#58, #59).

This commit is contained in:
Cotes Chung 2020-05-23 15:54:11 +08:00
parent bcd394598b
commit 7382eaa953
2 changed files with 50 additions and 13 deletions

28
_data/contact.yml Normal file
View file

@ -0,0 +1,28 @@
# The contact options.
# v2.3
# https://github.com/cotes2020/jekyll-theme-chirpy
# © 2020 Cotes Chung
# MIT Licensed
-
type: github
icon: 'fab fa-github-alt'
-
type: twitter
icon: 'fab fa-twitter'
-
type: email
icon: 'fas fa-envelope'
noblank: true # open link in current tab
-
type: rss
icon: 'fas fa-rss'
noblank: true
# Complete the url below to enable more contact options
-
icon: 'fab fa-linkedin' # icons powered by <https://fontawesome.com/>
url: '' # Fill with your Linkedin homepage
-
icon: 'fab fa-stack-overflow'
url: '' # Fill with your stackoverflow homepage

View file

@ -64,18 +64,27 @@
<span class="icon-border"></span>
{% endif %}
<a href="https://github.com/{{ site.github.username }}" target="_blank">
<i class="fab fa-github-alt"></i>
</a>
<a href="https://twitter.com/{{ site.twitter.username }}" target="_blank">
<i class="fab fa-twitter"></i>
</a>
{% for entry in site.data.contact %}
{% capture url %}
{%- if entry.type == 'github' -%}
https://github.com/{{ site.github.username }}
{%- elsif entry.type == 'twitter' -%}
https://twitter.com/{{ site.twitter.username }}
{%- elsif entry.type == 'email' -%}
{% assign email = site.social.email | split: '@' %}
<a href="javascript:window.open('mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@'))">
<i class="fas fa-envelope"></i>
</a>
<a href="{{ site.baseurl }}/feed.xml" target="_blank">
<i class="fas fa-rss"></i>
javascript:window.open('mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@'))
{%- elsif entry.type == 'rss' -%}
{{ "/feed.xml" | relative_url }}
{%- else -%}
{{ entry.url }}
{%- endif -%}
{% endcapture %}
{% if url != '' %}
<a href="{{ url }}" {% unless entry.noblank %}target="_blank"{% endunless %}>
<i class="{{ entry.icon }}"></i>
</a>
{% endif %}
{% endfor %}
</div>