2021-02-19 23:33:19 +08:00
|
|
|
/**
|
|
|
|
* wiki v1 | https://github.com/xaoxuu/hexo-theme-stellar/
|
|
|
|
*/
|
|
|
|
|
|
|
|
hexo.extend.generator.register('wiki', function (locals) {
|
2021-02-22 14:12:34 +08:00
|
|
|
var hasWiki = false;
|
|
|
|
locals.pages.forEach((page, i) => {
|
|
|
|
if (page.layout == 'wiki') {
|
|
|
|
hasWiki = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
if (hasWiki) {
|
2021-07-04 20:21:31 +08:00
|
|
|
var ret = [];
|
|
|
|
ret.push({
|
2021-02-22 14:12:34 +08:00
|
|
|
path: (hexo.config.wiki_dir || 'wiki') + '/index.html',
|
2021-07-04 20:21:31 +08:00
|
|
|
data: {'filter': false},
|
2021-02-22 14:12:34 +08:00
|
|
|
layout: ['wiki']
|
2021-07-04 20:21:31 +08:00
|
|
|
});
|
|
|
|
if (hexo.theme.config.wiki && hexo.theme.config.wiki.groups) {
|
|
|
|
for (let group_name of Object.keys(hexo.theme.config.wiki.groups)) {
|
|
|
|
let group = hexo.theme.config.wiki.groups[group_name];
|
|
|
|
ret.push({
|
|
|
|
path: group.path,
|
|
|
|
data: {
|
|
|
|
'filter': true,
|
|
|
|
'title': group.title,
|
|
|
|
'group': group.title
|
|
|
|
},
|
|
|
|
layout: ['wiki']
|
|
|
|
});
|
|
|
|
}
|
2021-02-22 14:12:34 +08:00
|
|
|
}
|
2021-07-04 20:21:31 +08:00
|
|
|
return ret;
|
2021-02-22 14:12:34 +08:00
|
|
|
} else {
|
|
|
|
return {};
|
2021-02-19 23:33:19 +08:00
|
|
|
}
|
2021-02-22 14:12:34 +08:00
|
|
|
});
|