Skip to content

Commit 415b995

Browse files
committed
add support for dynamic "share" links on posts
1 parent 3c8532a commit 415b995

File tree

3 files changed

+32
-3
lines changed

3 files changed

+32
-3
lines changed

_includes/social_media_share_url.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{% if include.service == 'facebook' %}
2+
{% capture share_url %}
3+
https://www.facebook.com/sharer/sharer.php?u={{ include.permalink | prepend: site.url | prepend: site.baseurl | url_encode }}
4+
{% endcapture %}
5+
{% elsif include.service == 'linkedin' %}
6+
{% capture share_url %}
7+
https://www.linkedin.com/shareArticle?mini=true&url={{ include.permalink | prepend: site.url | prepend: site.baseurl | url_encode }}&title={{ include.title | url_encode }}&source=LinkedIn
8+
{% endcapture %}
9+
{% elsif include.service == 'twitter' %}
10+
{% capture share_url %}
11+
https://twitter.com/share?text={{ include.title | url_encode }}&url={{ include.permalink | prepend: site.url | prepend: site.baseurl | url_encode }}
12+
{% endcapture %}
13+
{% endif %}{{ share_url | strip }}

_layouts/post.html

+16
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,22 @@ <h1 class="f00-light lh-condensed">{{ page.title }}</h1>
2424
<p class="f5"><a href="/" class="d-flex flex-items-center {% if site.style == 'dark' %}text-white{% endif %}">{% octicon chevron-left height:16 class:"mr-2 v-align-middle" fill:{{ icon_color }} aria-label:Home %}Home</a></p>
2525
<h1 class="f00-light lh-condensed">{{ page.title }}</h1>
2626
<p class="{% if site.style == 'dark' %}text-white{% else %}text-gray{% endif %} mb-5">Published {{ page.date | date: "%b %d, %Y"}}</p>
27+
{% if site.social_media %}
28+
<div class="col-sm-4 col-lg-3 d-flex flex-wrap flex-items-center d-sm-block float-sm-right border rounded-2 bg-white p-3 mb-5 ml-md-5">
29+
<h3 class="mr-3 mr-sm-0">Share</h3>
30+
<ul class="d-flex d-sm-block list-style-none">
31+
{% for account in site.social_media %}
32+
<li class="mt-sm-3">
33+
{% assign service_shortname = account[0] %}
34+
{% assign service = site.data.social_media[service_shortname] %}
35+
<a href="{% include social_media_share_url.html service=service_shortname title=page.title permalink=page.url %}" title="Share on {{ service.name }}" class="d-flex flex-items-center">
36+
<div style="width:32px">{{ service.icon_svg }}</div><span class="d-none d-sm-inline-block text-gray-light">{{ service.name }}</span>
37+
</a>
38+
</li>
39+
{% endfor %}
40+
</ul>
41+
</div>
42+
{% endif %}
2743
<div class="article">
2844
{{ content }}
2945
</div>

_sass/_highlight-syntax.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.highlight { background: #ffffff; }
1+
.highlight { width: 100%; overflow: auto; background: #ffffff; }
22
.highlight .c { color: #999988; font-style: italic } /* Comment */
33
.highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */
44
.highlight .k { font-weight: bold } /* Keyword */
@@ -60,6 +60,6 @@
6060
.highlight .il { color: #009999 } /* Literal.Number.Integer.Long */
6161

6262
/* Make line numbers unselectable: excludes line numbers from copy-paste user ops */
63-
.highlight .lineno {-webkit-user-select: none;-moz-user-select: none; -o-user-select: none;}
63+
.highlight .lineno {-webkit-user-select: none;-moz-user-select: none; -o-user-select: none;}
6464
.lineno::-moz-selection {background-color: transparent;} /* Mozilla specific */
65-
.lineno::selection {background-color: transparent;} /* Other major browsers */
65+
.lineno::selection {background-color: transparent;} /* Other major browsers */

0 commit comments

Comments
 (0)