Love this approach and implemented it myself.
A little enhancment is auto loading all the components ( at this moment only viable for single shortcakes ) but maybe this is interesting for you too.
// eleventy.js
const autoload = require('require-dir');
const components = './_includes/components';
const files = autoload(components);
// in the config function itself
Object.keys(files).forEach(component => { config.addShortcode(component,files[component]); });
Love this approach and implemented it myself.
A little enhancment is auto loading all the components ( at this moment only viable for single shortcakes ) but maybe this is interesting for you too.
// eleventy.js
const autoload = require('require-dir');const components = './_includes/components';const files = autoload(components);// in the config function itself
Object.keys(files).forEach(component => { config.addShortcode(component,files[component]); });