在Octopress添加新浪微博按钮 札记

其实很简单的,只是对网络技术忘得差不多了,所以花了一点时间

Prepare

  • http://open.weibo.com/sharebutton 去申请一个 share button, 申请之后看到有WBML方法, 和JS方法。 我这里选择的是WBML方法

Steps

  • source/_includes/head.html 里面修改,添加xmlns:
1
2
3
- <!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
+ <!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en" xmlns:wb="http://open.weibo.com/wb"><!--<![endif]-->

  • </head> 之前添加script语句:
    1
    2
    
    + <!-- load sina weibo share -->
    + <script src="http://tjs.sjs.sinajs.cn/open/api/js/wb.js?appkey=" type="text/javascript" charset="utf-8"></script>
    
  • source/_includes/post/sharing.html 里面添加Button
1
2
3
{ % if site.weibo_share % }
    <wb:share-button relateuid="xxxxxxxx" title="Share a blog  <<[object Object]>>" ></wb:share-button>
{ % endif % }

这里site.weibo_share 是用于在 _config.yml 上修改的,relateduid 就是你新浪微博的id, 当然这是自动生成的,另外title参数 请看 这个列表, 我这里就加了一个title

  • 为了让上述改动有效在 _config.yml 添加一点信息:
1
2
+ #weibo share
+ weibo_share: true

After

markdown 似乎在解析的时候遇到codeblock 会打断number list 这个bug已经解决的 但是好像没有merge 需要手动merge