插件名称:
生成一个类似 MovableType 的档案
代码参考以下基友之作:
https://gist.github.com/ilkka/707909
https://gist.github.com/ilkka/707020
https://gist.github.com/nlindley/6409459
安装
使用插件,
将 category_archive_plugin.rb
文件放入 Jekyll 工程的 _plugins
目录。
复制一份 _layouts/category_archive.html
文件到 _layouts
目录,内容可自行修改。
参数配置
在网站的配置文件中添加 category_archive
键,指定布局 layout
属性,默认为 category_archive
。
category_archive:
layout: “category_archive”
如果在配置文件中 category_archive
设置了 path
属性键,归档生成目录路径则为 PATH/CATEGORY/index.html
。 PATH
被 path
替换,CATEGORY
为文档分类名称,默认是空字符串。
category_archive:
layout: “category_archive”
path: /archives
如果设置 slugify
键为 true
, then category URLs will be slugified. ie: the url for “My Category” will be ‘categories/my-category’ not ‘categories/My%20Category’
模板中使用 Liquid 变量
page.category
包含分类名称
链接分类文档
本插件提供自定义 liquid 块标签,categorylink
,可以被使用渲染链接一个分类的文档,例如: This plugin provides the custom liquid block tag, categorylink
, which can be used to render a link to a category’s archive. For example:
{% categorylink foo %} 链接 foo {% endcategorylink %}
将创建一个链接到目录的档案 foo
与内容”,这是一个链接到foo”。在此外,如果指定了一个变量的名称,而不是一个类别,则该变量将被扩展每一个时间标签块被渲染。
Would create a link to the category archive of foo
with the content “This is a link to foo”. In addition, if the name of a variable is specified instead of a category, the variable will be expanded every time the tag block is rendered.