Comment on page
Hexo
如何在 Hexo 開發環境的文章中加入 LikeCoin button
在
themes/next/layout/_custom/
目錄下新增一檔案 like_coin.ejs
並貼上下列程式碼,並將 [LikerID] 更改為你的 Liker ID。<div>
<script type="text/javascript">
document.write(
"<iframe scrolling='no' frameborder='0' sandbox='allow-scripts allow-same-origin allow-popups allow-popups-to-escape-sandbox allow-storage-access-by-user-activation' style='height: 212px; width: 100%;' src='https://button.like.co/in/embed/[LikerID]/button?referrer=" +
encodeURIComponent(location.href.split("?")[0].split("#")[0]) + "'></iframe>");
</script>
<div>
打開
themes/next/layout/_macro/post.swig
在合適的位置把 like_coin.ejs
放置好 {% if theme.related_posts.enable and (theme.related_posts.display_in_home or not is_index) %}
+ {% include '../_custom/like_coin.ejs' %}
{% include '../_partials/post/post-related.swig' with { post: post } %}
{% endif %}
如果您沒有開啟相關文章的話,則加在往上幾行的
{{ post.content }}
後方 {% else %}
{% if post.type === 'picture' %}
<a href="{{ url_for(post.path) }}">{{ post.content }}</a>
{% else %}
{{ post.content }}
+ {% include '../_custom/like_coin.ejs' %}
{% endif %}
{% endif %}
{% else %}
{{ post.content }}
+ {% include '../_custom/like_coin.ejs' %}
{% endif %}
</div>
完成後就可以看到讚賞鍵出現在文章中。
Last modified 2yr ago