This commit is contained in:
afc163 2015-05-09 17:36:15 +08:00
parent 70b0829836
commit 06a97ff5cb
7 changed files with 83 additions and 32 deletions

26
nico.js Normal file
View File

@ -0,0 +1,26 @@
var path = require('path');
// {{ settings for nico
exports.theme = 'theme';
exports.source = process.cwd();
exports.output = path.join(process.cwd(), '_site');
exports.permalink = '{{directory}}/{{filename}}';
exports.ignorefilter = function(filepath, subdir) {
var extname = path.extname(filepath);
if (extname === '.tmp' || extname === '.bak') {
return false;
}
if (/\.DS_Store/.test(filepath)) {
return false;
}
if (/^(_site|_theme|node_modules|\.idea)/.test(subdir)) {
return false;
}
return true;
};
exports.writers = [
'nico.PageWriter',
'nico.StaticWriter',
'nico.FileWriter'
];
// end settings }}

View File

@ -1,13 +0,0 @@
{
"source": ".",
"output": "_site",
"theme": "theme",
"sitename": "Ant Design",
"siteurl": "",
"permalink": "{{directory}}/{{filename}}",
"writers": [
"nico.PageWriter",
"nico.FileWriter",
"nico.StaticWriter"
]
}

View File

@ -16,7 +16,7 @@
},
"scripts": {
"build": "npm run clean && nico build",
"start": "npm run clean && nico server",
"start": "npm run clean && nico server --watch",
"clean": "rm -rf _site",
"deploy": "npm run build && gh-pages -d _site -b master"
}

View File

@ -1 +1,8 @@
aside
{%- set items = resource.pages|find_category(post.meta.category) %}
<aside>
<ul>
{%- for item in items %}
<li><a href="{{permalink_url(item)}}">{{item.title}}</a></li>
{%- endfor %}
</ul>
</aside>

View File

@ -3,7 +3,7 @@
{% block title %}{{post.title}} - {{config.site.name}}{% endblock %}
{% block description %}{% if post.summay %}{{post.summary}}{% endif %}{% endblock %}
{% block main -%}
{%- include "aside.html" %}
{%- include "aside.html" %}
<article class="markdown">
<h1>{{ post.title }}</h1>
{{ post.html }}

View File

@ -29,7 +29,7 @@
</li>
<li><a href="/docs/instruction">原则</a>
</li>
<li><a href="/docs/components">组件</a>
<li><a href="/components/button">组件</a>
</li>
<li><a href="/docs/modes">模式</a>
</li>
@ -41,6 +41,9 @@
</nav>
<div class="nav-phone-icon"></div>
</header>
{%- if post.meta.template === 'component' %}
{%- include "aside.html" %}
{%- endif %}
{%- if post.filename === 'index' %}
<div class="main">
<div class="main-box" id="main">

View File

@ -1,16 +1,44 @@
exports.reader = function(post) {
var filename = post.meta.filepath.toLowerCase();
if (filename.indexOf('components') >= 0) {
post.template = post.meta.template = 'component';
} else {
post.template = post.meta.template = (post.meta.template || 'page');
}
if (filename === 'readme.md') {
post.filename = post.meta.filename = 'index';
post.meta.category = 'docs';
}
if (!post.meta.category) {
post.meta.category = post.meta.directory;
}
return post;
module.exports = function(nico) {
var exports = {};
exports.reader = function(post) {
var filename = post.meta.filepath.toLowerCase();
if (filename.indexOf('components') >= 0) {
post.template = post.meta.template = 'component';
} else {
post.template = post.meta.template = (post.meta.template || 'page');
}
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;
};
exports.filters = {
find_category: function(pages, cat) {
var ret = [];
Object.keys(pages).forEach(function(key) {
var item = nico.sdk.post.read(key);
if (item.meta.category === cat) {
ret.push(item);
}
});
ret = ret.sort(function(a, b) {
if (/index$/i.test(a.filename)) {
a.meta.order = 1;
}
if (/index$/i.test(b.filename)) {
b.meta.order = 1;
}
a = a.meta.order || 10;
b = b.meta.order || 10;
return parseInt(a, 10) - parseInt(b, 10);
});
return ret;
}
};
return exports;
};