I am using Ghost as an npm module following this guide.
I would like to add some custom helpers that I can leverage inside of my themes. Is there a way to do this without changing code inside the Ghost module?
This is my current code:
const ghost = require('ghost');
const path = require('path');
const hbs = require('express-hbs');
const config = path.join(__dirname, 'config.js');
const coreHelpers = {};
coreHelpers.sd_nls = require('./sd_nls');
// Register a handlebars helper for themes
function registerThemeHelper(name, fn) {
hbs.registerHelper(name, fn);
}
registerThemeHelper('sd_nls', coreHelpers.sd_nls);
ghost({ config: config })
.then(ghostServer => ghostServer.start());
I think one possible problem is that my hbs is a new handlebars instance, not the same one used by Ghost, therefore when Ghost runs it doesn't include any helpers I've registered.