Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(load_theme_config): support alternate theme config #4120

Merged
merged 1 commit into from
Feb 25, 2020

Conversation

SukkaW
Copy link
Member

@SukkaW SukkaW commented Feb 9, 2020

What does it do?

The part of #3890

theme_config in _config.yml looks good, but it is better to have a separate theme config. We could introduce _config.[name].yml. Currently, theme_config has higher priority than _config.yml under theme directories. After bring up _config.[name].yml, I suggest the theme_config in _config.yml > _config.[name].yml > _config.yml under theme directories which will retain highest priority for theme_config.

How to test

git clone -b theme-config-dedicated https://github.com/sukkaw/hexo.git
cd hexo
npm install
npm test

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

@SukkaW SukkaW requested review from tomap, curbengh and a team February 9, 2020 16:05
});

it('_config.[theme].json exists', () => {
const configPath = join(hexo.base_dir, '_config.test_theme.json');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this feature will allow other than YAML format?

Copy link
Member Author

@SukkaW SukkaW Feb 16, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since I just port the feature from load_config, if Hexo support _config.json, then _config.test_theme.json should be supported as well (That's why I include this in test cases)

@SukkaW SukkaW merged commit b53ac97 into hexojs:master Feb 25, 2020
@SukkaW SukkaW added the enhancement New feature or request label Apr 20, 2020
@stevenjoezhang
Copy link
Member

stevenjoezhang commented Apr 26, 2020

Currently theme_config only affects template local

theme.config = deepMerge(theme.config, config.theme_config);

Which means something like

hexo.extend.filter.register('', () => {
  let { key } = hexo.theme.config;
  // If the key is defined in `theme_config`, it would be null here
}, 0);

does not work.

Is it possible to merge config.theme_config into theme.config after ctx.theme loads?

See also iissnan/hexo-theme-next#328 ink-zone/fexo#157

Update: #4360

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants