Makes finally dynamic component work??
This commit is contained in:
@@ -1,15 +1,31 @@
|
||||
import type { PageLoad } from './$types';
|
||||
|
||||
export const load: PageLoad = async ({ data }) => {
|
||||
for (const group of data.config.services) {
|
||||
for (const service of group.items) {
|
||||
const config = { ...data.config };
|
||||
const groups: Array<string> = Object.entries(config.services).map(([k, v]) => k);
|
||||
|
||||
const components: Record<string, any> = {};
|
||||
|
||||
for (const group of groups) {
|
||||
const services: Array<string> = Object.entries(config.services[group].items).map(
|
||||
([k, v]) => k
|
||||
);
|
||||
for (const s of services) {
|
||||
const service = data.config.services[group].items[s];
|
||||
|
||||
if (components[service.type || 'generic'] != undefined) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const path =
|
||||
'../lib/services/' + (service.componentPath || 'generic/GenericServiceCard.svelte');
|
||||
const module = await import(/* @vite-ignore */ path);
|
||||
|
||||
service.component = module.default;
|
||||
components[service.type || 'generic'] = module.default;
|
||||
|
||||
delete service.componentPath;
|
||||
}
|
||||
}
|
||||
return { config: data.config };
|
||||
|
||||
return { config, components };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user