kirbyup
Version:
Zero-config bundler for Kirby Panel plugins
25 lines (23 loc) • 614 B
JavaScript
const kirbyup = Object.freeze({
/**
* Auto-import Kirby Panel components, transformed by
* kirbyup's glob-import plugin for Vite.
*
* @example
* kirbyup.import('./components/blocks/*.vue')
*/
import(glob) {
const modules = glob;
return Object.entries(modules).reduce(
(accumulator, [path, component]) => {
accumulator[getComponentName(path)] = component.default;
return accumulator;
},
{}
);
}
});
function getComponentName(path) {
return path.substring(path.lastIndexOf("/") + 1, path.lastIndexOf(".")).toLowerCase();
}
export { kirbyup };