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.
Unfortunately even with the most recent version this still is a very recent issue. I tried to come up with my own 3-file-based solution that will take the original Ghost Dockerfile and build from there adding custom helpers from just one directory.
Find it here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With