Skip to content

💡enhancement: use autoload pattern #2

Description

@mittelgrau

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]); });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions