How get config from _config.yml in scripts? #4964
Answered
by
yoshinorin
gjssss
asked this question in
Question / Answer
-
When I use How can I get Theme Config |
Beta Was this translation helpful? Give feedback.
Answered by
yoshinorin
May 10, 2022
Replies: 1 comment 2 replies
-
In hexo // themes/<your_theme>/scripts/example.js
function themeConfigConsoleLog() {
console.log(this.config.theme_config);
}
// Please see: https://hexo.io/api/filter
hexo.extend.filter.register('after_init', themeConfigConsoleLog)
// Also you can use it in a template engin (e.g: EJS)
// https://hexo.io/docs/helpers
hexo.extend.helper.register('<helper_name>', themeConfigConsoleLog) If you have a // _theme.<your_theme>.yml
title: test You can see theme config when start a server. $ hexo server
INFO Validating config
{ title: 'test' }
INFO Start processing |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
gjssss
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@gjssss
In hexo
6.x.x
you can get the theme config values like the below way.If you have a
_theme.<your_theme>.yml
.You can see theme config when start a server.
$ hexo server INFO Validating config { title: 'test' } INFO Start processing