Say I have /scripts/blah.js:
/* global hexo */
hexo.extend.helper.register('someMethod', (arg1) => {
// can I access site.data here?
})
Is there a way to access site.data in a script file, in particular within a helper method? Or do I need to pass site.data into the helper as an argument?
a similar question here: https://github.com/hexojs/hexo/issues/3025
I didn't find some useful information about this in helper section of the document.
Helpers are called with the hexo context as this, so it would be:
hexo.extend.helper.register('someMethod', function (arg1) {
console.log(this.site.data)
})
This issue has been automatically marked as stale because lack of recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
Most helpful comment
Helpers are called with the hexo context as
this, so it would be: