afc163
10 years ago
7 changed files with 83 additions and 32 deletions
@ -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 }}
|
@ -1,13 +0,0 @@ |
|||
{ |
|||
"source": ".", |
|||
"output": "_site", |
|||
"theme": "theme", |
|||
"sitename": "Ant Design", |
|||
"siteurl": "", |
|||
"permalink": "{{directory}}/{{filename}}", |
|||
"writers": [ |
|||
"nico.PageWriter", |
|||
"nico.FileWriter", |
|||
"nico.StaticWriter" |
|||
] |
|||
} |
@ -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> |
|||
|
@ -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; |
|||
}; |
|||
|
Loading…
Reference in new issue