32 lines
866 B
TypeScript
32 lines
866 B
TypeScript
import type { PageLoad } from './$types';
|
|
|
|
export const load: PageLoad = async ({ data }) => {
|
|
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);
|
|
|
|
components[service.type || 'generic'] = module.default;
|
|
|
|
delete service.componentPath;
|
|
}
|
|
}
|
|
|
|
return { config, components };
|
|
};
|