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
|
|
|
});
|
2021-07-26 22:26:46 +08:00
|
|
|
if (hexo.theme.config.wiki && hexo.theme.config.wiki.all_tags) {
|
|
|
|
for (let id of Object.keys(hexo.theme.config.wiki.all_tags)) {
|
|
|
|
let tag = hexo.theme.config.wiki.all_tags[id];
|
2021-07-04 20:21:31 +08:00
|
|
|
ret.push({
|
2021-07-26 22:26:46 +08:00
|
|
|
path: tag.path,
|
2021-07-04 20:21:31 +08:00
|
|
|
data: {
|
|
|
|
'filter': true,
|
2021-07-26 22:26:46 +08:00
|
|
|
'tagName': tag.name
|
2021-07-04 20:21:31 +08:00
|
|
|
},
|
|
|
|
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
|
|
|
});
|