From 7382eaa953a34d849d8e8d30274f4ebce14c699f Mon Sep 17 00:00:00 2001 From: Cotes Chung <11371340+cotes2020@users.noreply.github.com> Date: Sat, 23 May 2020 15:54:11 +0800 Subject: [PATCH] Feature: make contact options configurable (#58, #59). --- _data/contact.yml | 28 ++++++++++++++++++++++++++++ _includes/sidebar.html | 35 ++++++++++++++++++++++------------- 2 files changed, 50 insertions(+), 13 deletions(-) create mode 100644 _data/contact.yml diff --git a/_data/contact.yml b/_data/contact.yml new file mode 100644 index 0000000..a6ec500 --- /dev/null +++ b/_data/contact.yml @@ -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 + url: '' # Fill with your Linkedin homepage +- + icon: 'fab fa-stack-overflow' + url: '' # Fill with your stackoverflow homepage \ No newline at end of file diff --git a/_includes/sidebar.html b/_includes/sidebar.html index 4101431..6deb037 100644 --- a/_includes/sidebar.html +++ b/_includes/sidebar.html @@ -64,18 +64,27 @@ {% endif %} - - - - - - - {% assign email = site.social.email | split: '@' %} - - - - - - + {% 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: '@' %} + javascript:window.open('mailto:' + ['{{ email[0] }}','{{ email[1] }}'].join('@')) + {%- elsif entry.type == 'rss' -%} + {{ "/feed.xml" | relative_url }} + {%- else -%} + {{ entry.url }} + {%- endif -%} + {% endcapture %} + + {% if url != '' %} + + + + {% endif %} + {% endfor %} \ No newline at end of file