Makes finally dynamic component work??

This commit is contained in:
2023-08-11 17:04:39 +02:00
parent 09304b9a95
commit 9903497867
6 changed files with 69 additions and 52 deletions

View File

@@ -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 };
};