hexojs / hexo-renderer-stylus

Stylus renderer for Hexo
MIT License
18 stars 19 forks source link

if hexo-config support get attr from site config file #11

Closed cbvar closed 4 years ago

cbvar commented 8 years ago

When i call hexo-config('root') from styl file, it return empty because theme lack of 'root' attr. So i think that if hexo-config shoud support get attr from site config file again, or how to handle the root problem?

sebdeckers commented 8 years ago

@cbvar I just faced the same problem. It looks like we have to use the theme configuration (/themes/your-theme-name/_config.yml) instead of the main Hexo configuration file (/_config.yml).

@tommy351 Would it not make sense to allow looking up in the main configuration properties? Maybe as a fallback, so it would not break existing themes. My use case is to read the url and root properties to generate absolute URLs in CSS.

kgraves commented 7 years ago

I also just ran into needing this for a Hexo project. Only the theme's config is available through hexo-config, but I want to be able to customize my site through settings in my config file. To be backwards compatible like @cbas suggested, something like the following might suffice:

style.define('hexo-site-config', function(data) {
  return getProperty(self.config, data.val);
});
tomap commented 5 years ago

Those lines seem to solve this question: https://github.com/hexojs/hexo-renderer-stylus/blob/master/lib/renderer.js#L5

doesn't it?

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stevenjoezhang commented 4 years ago

Use theme_config

https://github.com/hexojs/hexo-renderer-stylus/pull/41