Octopress自身不支持评论功能,不过我们可以使用第三方的评论系统,国外的有Disqus。下面介绍怎样在Octopress中使用Disqus。
首先需要在Disqus注册一个账号,登录后点击Add Disqus to your site,然后添加站点信息site name和url,记下右侧的name
然后在_config.yml文件中进行下面设置
# encoding: UTF-8
module Jekyll
class CategoryListTag < Liquid::Tag
def render(context)
html = ""
categories = context.registers[:site].categories.keys
categories.sort.each do |category|
posts_in_category = context.registers[:site].categories[category].size
category_dir = context.registers[:site].config['category_dir']
html << "<li class='category'><a href='/#{category_dir}/#{category.to_url}/'>#{category} (#{posts_in_category})</a></li>\n"
end
html
end
end
end
Liquid::Template.register_tag('category_list', Jekyll::CategoryListTag)
--- a/plugins/tag_cloud.rb
+++ b/plugins/tag_cloud.rb
@@ -54,7 +54,7 @@ def initialize(name, params, tokens)
# map: [[tag name, tag count]] -> [[tag name, tag weight]]
weighted = count.map do |name, count|
# logarithmic distribution
- weight = (Math.log(count) - Math.log(min))/(Math.log(max) - Math.log(min))
+ weight = count
[name, weight]
end
# get the top @limit tag pairs when a limit is given, unless the sort method is random
@@ -92,12 +92,17 @@ def initialize(name, params, tokens)
html = ""
# iterate over the weighted tag Array and create the tag items
weighted.each_with_index do |tag, i|
- name, weight = tag
+ name, weight_orig = tag
+ if min == max
+ weight = 0.5
+ else
+ weight = (Math.log(weight_orig) - Math.log(min))/(Math.log(max) - Math.log(min))
+ end
size = size_min + ((size_max - size_min) * weight).to_f
size = sprintf("%.#{@precision}f", size)
slug = name.to_url
@separator = "" if i == (weighted.size - 1)
- html << "#{@tag_before}<a style=\"font-size: #{size}#{unit}\" href=\"/#{dir}/#{slug}/\">#{name}</a>#{@separator}#{@tag_after}\n"
+ html << "#{@tag_before}<a style=\"font-size: #{size}#{unit}\" href=\"/#{dir}/#{slug}/\">#{name}(#{weight_orig})</a>#{@separator}#
end
html
end
如果会出现:
添加超过一个tags之后,rake generate就会开始报错了: Error :Liquid Exception: comparison of Array with Array failed in page
只需要将1个tag重复2次以上使用就可以解决。
1.第1个post加的tag是:tag1,第2个post加的tag是:tag1
2.rake generate
3.第2个post的tag随便改:tagXXX