hexo-theme-stellar/scripts/generators/wiki.js

39 lines
880 B
JavaScript
Raw Normal View History

2021-02-19 23:33:19 +08:00
/**
* wiki v1 | https://github.com/xaoxuu/hexo-theme-stellar/
*/
hexo.extend.generator.register('wiki', function (locals) {
2024-01-14 17:21:19 +08:00
const { site_tree, wiki } = hexo.theme.config
2024-01-14 16:42:20 +08:00
const wikiIdList = Object.keys(wiki.tree)
if (wikiIdList.length == 0) {
return {}
}
var ret = []
ret.push({
2024-01-14 17:21:19 +08:00
path: site_tree.wiki.base_dir + '/index.html',
2024-01-14 16:42:20 +08:00
layout: ['index_wiki'],
data: {
layout: 'index_wiki',
2024-01-14 17:21:19 +08:00
menu_id: site_tree.wiki.menu_id,
2024-01-14 16:42:20 +08:00
filter: false
2021-02-22 14:12:34 +08:00
}
2024-01-14 16:42:20 +08:00
})
if (wiki.all_tags) {
for (let id of Object.keys(wiki.all_tags)) {
let tag = wiki.all_tags[id]
ret.push({
path: tag.path,
layout: ['index_wiki'],
data: {
layout: 'index_wiki',
2024-01-14 17:21:19 +08:00
menu_id: site_tree.wiki.menu_id,
2024-01-14 16:42:20 +08:00
filter: true,
2024-01-19 01:05:44 +08:00
tagName: tag.name,
title: tag.name
2024-01-14 16:42:20 +08:00
}
})
2021-02-22 14:12:34 +08:00
}
2021-02-19 23:33:19 +08:00
}
2024-01-14 16:42:20 +08:00
return ret
})