-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathsocial-share.liquid
78 lines (70 loc) · 2.62 KB
/
social-share.liquid
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
{% comment %}
Social Share snippet
- usable with products or articles
- uses BEM conventions
- and Font-Awesome icons by default
Usage:
{% include 'social-share' with product %}
or:
{% include 'social-share' with article %}
TODO: needs testing!
{% endcomment %}
{% comment %}
Safe-guard against argument not being passed
{% endcomment %}
{% if social-share == blank and product %}
{% assign social-share = product %}
{% endif %}
{% comment %}
duck-type argument:
If argument passed is a product, get the product image url
{% endcomment %}
{% if social-share.variants %}
{% assign social_share_img_url = social-share.featured_image.src | product_img_url: 'grande' %}
{% comment %}
Else the argument passed is an article, get the article image url
{% endcomment %}
{% else %}
{% assign social_share_img_url = social-share.image | img_url: 'grande' %}
{% endif %}
<ul class="ul--inline social-share social-icons social-share--{{ social-share }}">
{% if settings.twittercard_handle != blank %}
<li>
<a class="social-icon social-icon--twitter"
target="_blank"
title="{{ shop.name }} on Twitter"
href="//twitter.com/share?text={{ settings.twittercard_handle }}&?url={{ shop.url }}{{ social-share.url }}">
<i class="fa fa-twitter"></i>
</a>
</li>
{% endif %}
<li>
<a class="social-icon social-icon--facebook"
target="_blank"
href="//facebook.com/sharer.php?u={{ shop.url }}{{ social-share.url }}&t={{ social-share.title }}">
<i class="fa fa-facebook"></i>
</a>
</li>
<li>
<a class="social-icon social-icon--pinterest"
target="_blank"
href="http://pinterest.com/pin/create/button/?url={{ shop.url }}{{ social-share.url }}&media={{ social_share_img_url }}&description={{ social-share.title }}">
<i class="fa fa-pinterest"></i>
</a>
</li>
<li>
<a class="social-icon social-icon--envelope"
target="_blank"
href="mailto:?subject={{ social-share.title }}&body={{ shop.url }}{{ social-share.url }}" title="Share by Email">
<i class="fa fa-envelope"></i>
</a>
</li>
</ul>
{% comment %}
alternative pinterest button
{% endcomment %}
{% comment %}
<a href='javascript:void((function()%7Bvar%20e=document.createElement('script');e.setAttribute('type','text/javascript');e.setAttribute('charset','UTF-8');e.setAttribute('src','http://assets.pinterest.com/js/pinmarklet.js?r='+Math.random()*99999999);document.body.appendChild(e)%7D)());'>
<img src="{{ 'img-pintrest.png' | asset_url }}" alt="Pinterest">
</a>
{% endcomment %}