我希望用户能够喜欢 Shopify 网站的博客页面上的单个文章。我在博客循环中添加了我的社交媒体图标。
博客液体
{% for article in blog.articles %}<!-- START ENTRY {{ forloop.index }} -->
<div id="post{{ article.id }}">
{{ article.content | strip_html | truncate: 40 }} <br/> <a href="{{ article.url}}">Read More</a>
{% assign description = article.title | escape | replace:' ','%20' %}
{% assign link = article.url %}
{% include 'social' %}
</div>
{% endfor %}
social.liquid 片段
<div class="social-plugins">
<span class="twitter">
<a href="http://twitter.com/share"{% if template == 'product' or template == 'article' or template == 'blog' %} data-url="{{ shop.url }}{{ link }}"{% endif %} data-text="{% if template == 'product' %}{{ product.title | escape }} by {{ product.vendor | escape }}{% elsif template == 'blog' %}{{ social.title | escape }}{% else %}{{ page_title | escape }}{% endif %}" class="twitter-share-button" data-count="horizontal" data-via="bondiNYC">Tweet</a>
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
</span>
<span class="facebook">
<iframe src="//www.facebook.com/plugins/like.php?href={{shop.url}}{{link}}&send=false&layout=button_count&width=100&show_faces=false&action=like&colorscheme=light&font&height=21" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"</iframe>
</span>
<span class="pinterest">
<a href="http://pinterest.com/pin/create/button/?url={{ shop.url }}{{ link }}&description={{ description }}&media={{src | escape}}" class="pin-it-button" count-layout="none">Pin It</a>
</span>
</div>
如果我只输入 {{shop.url}}{{blog.url}},则赞按钮有效,但当我添加 {{shop.url}}{{link}} 时则无效。{{link}} 是根据页面分配的。