发现在octopress似乎没有现成可以放在sidebar的分类,于是自己动手弄一个,首先你可以增加个category_list.rb防止在Octoprss的plugins文件夹下
# encoding: utf-8
module Jekyll
class Site
def create_category_list
write_to_tag_cloud if @config['category_tag_cloud']
write_to_sidebar if @config['category_sidebar']
end
private
# generate category tag list and write to 'source/_includes/asides/categories_tag.html'
def write_to_tag_cloud
puts ' => Creating Categories Tag Cloud'
lists = {}
max, min = 1, 1
@categories.keys.sort_by{ |str| str.downcase }.each do |category|
count = @categories[category].count
lists[category] = count
max = count if count > max
end
html = ''
lists.each do | category, counter |
url = get_category_url category
style = "font-size: #{100 + (60 * Float(counter)/max)}%"
if @config['category_counter']
html << " <a href='#{url}' style='#{style}'>#{category.capitalize}(#{@categories[category].count})</a> "
else
html << " <a href='#{url}' style='#{style}'>#{category.capitalize}</a> "
end
end
File.open(File.join(@source, '_includes/asides/categories_tag.html'), 'w') do |file|
file << """{% if site.category_tag_cloud %}
<section>
<h1>#{@config['category_title'] || 'Categories'}</h1>
<span class='categories_tag'>#{html}</span>
</section>
{% endif %}
"""
end
end
# generate category lists and write to 'source/_includes/asides/categories_sidebar.html'
def write_to_sidebar
puts ' => Creating Categories Sidebar'
html = "<ul>\n"
# case insensitive sorting
@categories.keys.sort_by{ |str| str.downcase }.each do |category|
url = get_category_url category
if @config['category_counter']
html << " <li><a href='#{url}'>#{category.capitalize} (#{@categories[category].count})</a></li>\n"
else
html << " <li><a href='#{url}'>#{category.capitalize}</a></li>\n"
end
end
html << "</ul>"
File.open(File.join(@source, '_includes/asides/categories_sidebar.html'), 'w') do |file|
file << """{% if site.category_sidebar %}
<section>
<h1>#{@config['category_title'] || 'Categories'}</h1>
#{html}
</section>
{% endif %}
"""
end
end
def get_category_url(category)
dir = @config['category_dir'] || 'categories'
File.join @config['root'], dir, category.gsub(/_|\P{Word}/, '-').gsub(/-{2,}/, '-').downcase
end
end
class CategoryList < Generator
safe true
priority :low
def generate(site)
if site.config['category_list']
puts "## Generating Categories.."
site.create_category_list
end
end
end
end
打开根目录的_config.yml,加上一些设定
# ----------------------- #
# Categories #
# ----------------------- #
# create categories page
category_list: true
# use counter after categories
category_counter: true
# category title
category_title: 分類
# create an include categories list in @source/_includes/asides/categories_sidebar.html
# and don't forget to add 'asides/categories_sidebar.html' into @default_asides if you want to enable it.
category_sidebar: true
# create an include categories tag cloud page in @source/_includes/asides/categories_tag.html
# and don't forget to add 'asides/categories_tag.html' to @default_asides if you want to enable it.
category_tag_cloud: true
其中:
category_list 用来启用是否产生侧边栏分类
category_counter 用来决定是否要显示计数器
category_title 那么区块的标题
category_sidebar 效果维一个个排下来,如果文章分类很多可能会让页面拉得很长,如不喜欢可改用category_tag_cloud的效果
此外在_config.yml中要加一下你要include的区块
default_asides: [asides/about.html, asides/recent_posts.html, asides/categories_tag.html]
分享到:
相关推荐
并发同步,内存栅栏
黑客家庭自动节点 使设备能够与Hackers-HomeAuto-Server系统连接的节点软件 这是一个仓库,包含许多不同的Node实现,包括Python Flask应用程序,用于mqtt和http coms的Arduino代码等。
黑客-家庭自动服务器
Hackers: Heroes of the Computer Revolution by Steven Levy and Steven Levy 自己用html转成pdf的~
伯克利黑客 H @ B研讨会的示例和演示源文件。 目标 使用DCOS和相关的分布式系统部署示例“物联网”摄取管道。 作坊! 中提供了练习。
Machine Learning for Hackers (中文译名:机器学习-实用案例解析)通过实例讲解机器学习算法,用R实现的,可以一边学习机器学习一边学习R。 是实操型的书,重点放在讲怎么用R做数据挖掘,机器学习的算法更多的是...
使用Python从计算/理解第一,数学第二的角度介绍贝叶斯方法和概率编程。
Hackers delight 2nd edition黑客必备
The Bayesian method is the natural approach to inference, yet it is hidden from readers behind chapters of slow, mathematical analysis. The typical text on Bayesian inference involves two to three ...
Memory Barriers: a Hardware View for Software Hackers 讲解内存屏障的好论文,推荐!
Hackers and Painters,黑客与画家,写的非常不错的一本书,这是英文版的。
Linux Kernel Hackers' Guide Due to the fact that nearly every post to this site recently has been either by rude cracker- wannabes asking how to break into other people's systems or a request for ...
Bayesian Methods for Hackers 书的ipynb格式,可以直接用jupyter打开,书中的代码可直接按shift+enter执行
Linux Basics for Hackers: Getting Started with Networking, Scripting, and Security in Kali (AZW3)
Hackers
Addison Wesley - Hackers Delight__ 2002
Now that storage and collection technologies are cheaper and more precise, methods for extracting ... Machine Learning for Hackers is ideal for programmers from private, public, and academic sectors.