hexo-theme-stellar/scripts/events/lib/config.js

48 lines
1.3 KiB
JavaScript
Raw Normal View History

2021-02-19 23:33:19 +08:00
/**
* 部分代码借鉴自 NexT:
* https://github.com/next-theme/hexo-theme-next/blob/master/scripts/events/lib/config.js
*/
'use strict';
module.exports = hexo => {
2021-03-01 21:06:59 +08:00
2021-02-19 23:33:19 +08:00
const { cache, language_switcher } = hexo.theme.config;
const warning = function(...args) {
hexo.log.warn(`Since ${args[0]} is turned on, the ${args[1]} is disabled to avoid potential hazards.`);
};
if (cache && cache.enable && language_switcher) {
warning('language_switcher', 'caching');
cache.enable = false;
}
if (cache && cache.enable && hexo.config.relative_link) {
warning('caching', '`relative_link` option in Hexo `_config.yml`');
hexo.config.relative_link = false;
}
hexo.config.meta_generator = false;
// merge data
const data = hexo.locals.get('data');
if (data.widgets) {
for (let id of Object.keys(data.widgets)) {
hexo.theme.config.sidebar.widgets[id] = data.widgets[id];
}
}
2021-03-22 21:40:35 +08:00
// default menu
2021-07-26 22:26:46 +08:00
if (hexo.theme.config.sidebar.menu == undefined) {
2021-03-22 21:40:35 +08:00
hexo.theme.config.sidebar.menu = [];
}
2021-02-19 23:33:19 +08:00
// default widgets
2021-07-26 22:26:46 +08:00
if (hexo.theme.config.sidebar.widgets.repo_info == undefined) {
2021-07-04 22:53:55 +08:00
hexo.theme.config.sidebar.widgets.repo_info = {layout: 'repo_info'};
2021-03-22 21:40:35 +08:00
}
2021-07-26 22:26:46 +08:00
if (hexo.theme.config.sidebar.widgets.wiki_more == undefined) {
2021-02-19 23:33:19 +08:00
hexo.theme.config.sidebar.widgets.wiki_more = {layout: 'wiki_more'};
}
};