提交 5f135035 编写于 作者: A afc163

aside with category

上级 77367b18
# Button 按钮
- category: Component
---
这是一个按钮。
......
# Select 选择框
- category: Component
---
这是一个下拉选择器。
......
......@@ -12,6 +12,7 @@
},
"dependencies": {
"gh-pages-cli": "~0.2.0",
"lodash": "~3.8.0",
"nico": "*"
},
"scripts": {
......
......@@ -341,7 +341,15 @@ footer ul li > a {
height: 100%;
background: #F9F9F9;
position: absolute;
padding-top: 30px;
padding-top: 15px;
}
.aside-container li h4 {
font-size: 16px;
font-weight: bold;
padding-left: 50px;
margin: 10px 0;
color: #5C6B77;
}
.aside-container li a {
......
{%- set categories = resource.pages|get_all_category %}
{%- set items = resource.pages|find_category(post.meta.category) %}
<aside class="aside-container">
<ul>
{%- for item in items %}
<li class="{%- if item.title === post.title %}current{%- endif %}">
<a href="{{permalink_url(item)}}">{{item.title}}</a>
{%- for category in categories %}
<li>
<h4>{{category}}</h4>
<ul>
{%- for item in items %}
<li class="{%- if item.title === post.title %}current{%- endif %}">
<a href="{{permalink_url(item)}}">{{item.title}}</a>
</li>
{%- endfor %}
</ul>
</li>
{%- endfor %}
{%- endfor %}
</ul>
</aside>
var _ = require('lodash');
module.exports = function(nico) {
var exports = {};
......@@ -10,9 +12,7 @@ module.exports = function(nico) {
}
if (filename === 'readme.md') {
post.filename = post.meta.filename = 'index';
post.meta.category = 'docs';
}
post.meta.category = post.meta.category || post.meta.directory;
return post;
};
......@@ -37,6 +37,14 @@ module.exports = function(nico) {
return parseInt(a, 10) - parseInt(b, 10);
});
return ret;
},
get_all_category: function(pages) {
return _.uniq(Object.keys(pages).map(function(key) {
var item = nico.sdk.post.read(key);
return item.meta.category;
}).filter(function(item) {
return item;
}));
}
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册