vite-riot-template/src/js/registery.js

31 lines
680 B
JavaScript
Raw Normal View History

import {register, mount} from 'riot';
2022-12-18 21:28:21 +00:00
import HelloRiot from '../components/hello-riot/hello-riot.riot';
/**
* Register Global Components
2022-09-09 03:02:22 +00:00
*
* helper that registers and mounts global components
* via an object registry
2022-09-09 03:02:22 +00:00
*
* @param {Object} registry key:value object registry
*/
export function Register(registry = {}) {
Object.entries(registry).map(([name, component]) => {
register(name, component);
mount(name);
return {
name,
component
}
});
}
2022-12-18 21:28:21 +00:00
// define global components here
const registry = {
'hello-riot': HelloRiot
};
// export registered global components
export default Register(registry);