Skip to content

Commit

Permalink
Improved override option & Fixed theme_config in Hexo.
Browse files Browse the repository at this point in the history
1. Most options from Hexo, defined in `_data/next.yml` now merged into `hexo.config`.
2. All options from NexT, defined in main Hexo config now work correctly with `theme_config` prefix.
3. Updated `override` docs in NexT config.
  • Loading branch information
ivan-nginx committed Jan 18, 2018
1 parent 270484f commit 1b0b53a
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
6 changes: 4 additions & 2 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@
# Theme Core Configuration Settings
# ---------------------------------------------------------------

# Set to true, if you want to fully override the default configuration.
# Useful if you don't want to inherit the theme _config.yml configurations.
# If false, merge configs from `_data/next.yml` into default configuration (rewrite).
# If true, will fully override default configuration by options from `_data/next.yml` (override). Only for NexT settings.
# And if true, all config from default NexT `_config.yml` must be copied into `next.yml`. Use if you know what you are doing.
# Useful if you want to comment some options from NexT `_config.yml` by `next.yml` without editing default config.
override: false

# Allow to cache content generation. Introduced in NexT v6.0.0.
Expand Down
15 changes: 11 additions & 4 deletions scripts/merge-configs.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,25 @@
var merge = require('./merge');

/**
* Merge configs in _data/next.yml into hexo.theme.config.
* Note: configs in _data/next.yml will override configs in hexo.theme.config.
* Merge configs from _data/next.yml into hexo.theme.config.
* Note: configs in _data/next.yml will rewrite or override configs in hexo.theme.config.
*/
hexo.on('generateBefore', function () {
if (hexo.locals.get) {
var data = hexo.locals.get('data');
if ( data && data.next ) {
if ( data.next.override ) {
if (data && data.next) {
if (data.next.override) {
hexo.theme.config = data.next;
} else {
merge(hexo.config, data.next);
merge(hexo.theme.config, data.next);
}
/**
* If next.yml not exists, then merge all `theme_config.*`
* options from main Hexo config into hexo.theme.config.
*/
} else {
merge(hexo.theme.config, hexo.config.theme_config);
}
}
});
2 changes: 1 addition & 1 deletion source/css/main.styl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ $mixins = base $scheme custom;
// Variables Layer
// --------------------------------------------------
for $variable in $variables
@import "_variables/" + $variable
@import "_variables/" + $variable;


// Mixins Layer
Expand Down

0 comments on commit 1b0b53a

Please sign in to comment.