Skip to content

Commit cba2748

Browse files
committed
Feature: make contact options configurable (cotes2020#58, cotes2020#59).
1 parent 712be12 commit cba2748

2 files changed

Lines changed: 50 additions & 13 deletions

File tree

_data/contact.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# The contact options.
2+
# v2.3
3+
# https://github.com/cotes2020/jekyll-theme-chirpy
4+
# © 2020 Cotes Chung
5+
# MIT Licensed
6+
7+
-
8+
type: github
9+
icon: 'fab fa-github-alt'
10+
-
11+
type: twitter
12+
icon: 'fab fa-twitter'
13+
-
14+
type: email
15+
icon: 'fas fa-envelope'
16+
noblank: true # open link in current tab
17+
-
18+
type: rss
19+
icon: 'fas fa-rss'
20+
noblank: true
21+
22+
# Complete the url below to enable more contact options
23+
-
24+
icon: 'fab fa-linkedin' # icons powered by <https://fontawesome.com/>
25+
url: '' # Fill with your Linkedin homepage
26+
-
27+
icon: 'fab fa-stack-overflow'
28+
url: '' # Fill with your stackoverflow homepage

_includes/sidebar.html

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -64,18 +64,27 @@
6464
<span class="icon-border"></span>
6565
{% endif %}
6666

67-
<a href="https://github.com/{{ site.github.username }}" target="_blank">
68-
<i class="fab fa-github-alt"></i>
69-
</a>
70-
<a href="https://twitter.com/{{ site.twitter.username }}" target="_blank">
71-
<i class="fab fa-twitter"></i>
72-
</a>
73-
{% assign email = site.social.email | split: '@' %}
74-
<a href="javascript:window.open('mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@'))">
75-
<i class="fas fa-envelope"></i>
76-
</a>
77-
<a href="{{ site.baseurl }}/feed.xml" target="_blank">
78-
<i class="fas fa-rss"></i>
79-
</a>
67+
{% for entry in site.data.contact %}
68+
{% capture url %}
69+
{%- if entry.type == 'github' -%}
70+
https://github.com/{{ site.github.username }}
71+
{%- elsif entry.type == 'twitter' -%}
72+
https://twitter.com/{{ site.twitter.username }}
73+
{%- elsif entry.type == 'email' -%}
74+
{% assign email = site.social.email | split: '@' %}
75+
javascript:window.open('mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@'))
76+
{%- elsif entry.type == 'rss' -%}
77+
{{ "/feed.xml" | relative_url }}
78+
{%- else -%}
79+
{{ entry.url }}
80+
{%- endif -%}
81+
{% endcapture %}
82+
83+
{% if url != '' %}
84+
<a href="{{ url }}" {% unless entry.noblank %}target="_blank"{% endunless %}>
85+
<i class="{{ entry.icon }}"></i>
86+
</a>
87+
{% endif %}
88+
{% endfor %}
8089

8190
</div>

0 commit comments

Comments
 (0)