Start splitting in component the page.
This commit is contained in:
14
src/lib/components/ServiceCard.svelte
Normal file
14
src/lib/components/ServiceCard.svelte
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { ServiceConfig } from '$lib/config';
|
||||||
|
import { getServiceComponent } from '$lib/services/services';
|
||||||
|
|
||||||
|
export let service: ServiceConfig;
|
||||||
|
export let data: any;
|
||||||
|
|
||||||
|
const component = getServiceComponent(service.type || '');
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<p>{service.title}</p>
|
||||||
|
{#if component != undefined}
|
||||||
|
<svelte:component this={component} {data} />
|
||||||
|
{/if}
|
||||||
11
src/lib/components/ServiceGroup.svelte
Normal file
11
src/lib/components/ServiceGroup.svelte
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
import type { ServiceGroupConfig } from '$lib/config';
|
||||||
|
import ServiceCard from './ServiceCard.svelte';
|
||||||
|
|
||||||
|
export let group: ServiceGroupConfig;
|
||||||
|
export let groupData: Array<unknown>;
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#each group.items as service, i}
|
||||||
|
<ServiceCard {service} data={groupData[i]} />
|
||||||
|
{/each}
|
||||||
30
src/lib/config.ts
Normal file
30
src/lib/config.ts
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
export interface BrandConfig {
|
||||||
|
logo?: string;
|
||||||
|
icon?: string;
|
||||||
|
usemask?: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface SectionConfig extends BrandConfig {
|
||||||
|
title: string;
|
||||||
|
subtitle?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceConfig extends SectionConfig {
|
||||||
|
url: string;
|
||||||
|
target?: string;
|
||||||
|
type?: string;
|
||||||
|
|
||||||
|
[x: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ServiceGroupConfig extends SectionConfig {
|
||||||
|
items: Array<ServiceConfig>;
|
||||||
|
|
||||||
|
[x: string]: unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Config extends SectionConfig {
|
||||||
|
services: Array<ServiceGroupConfig>;
|
||||||
|
|
||||||
|
[x: string]: unknown;
|
||||||
|
}
|
||||||
@@ -2,37 +2,7 @@ import { writable, type Readable, type Writable, derived } from 'svelte/store';
|
|||||||
import configData from '../../config.yml';
|
import configData from '../../config.yml';
|
||||||
import { readFile, watch } from 'fs/promises';
|
import { readFile, watch } from 'fs/promises';
|
||||||
import * as yml from 'js-yaml';
|
import * as yml from 'js-yaml';
|
||||||
|
import type { Config, ServiceConfig, ServiceGroupConfig } from '$lib/config';
|
||||||
export interface BrandConfig {
|
|
||||||
logo?: string;
|
|
||||||
icon?: string;
|
|
||||||
usemask?: boolean;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface SectionConfig extends BrandConfig {
|
|
||||||
title: string;
|
|
||||||
subtitle?: string;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ServiceConfig extends SectionConfig {
|
|
||||||
url: string;
|
|
||||||
target?: string;
|
|
||||||
type?: string;
|
|
||||||
|
|
||||||
[x: string]: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface ServiceGroupConfig extends SectionConfig {
|
|
||||||
items: Array<ServiceConfig>;
|
|
||||||
|
|
||||||
[x: string]: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface Config extends SectionConfig {
|
|
||||||
services: Array<ServiceGroupConfig>;
|
|
||||||
|
|
||||||
[x: string]: unknown;
|
|
||||||
}
|
|
||||||
|
|
||||||
const requiredService: Required<ServiceConfig> = {
|
const requiredService: Required<ServiceConfig> = {
|
||||||
title: '',
|
title: '',
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
|
import ServiceGroup from '$lib/components/ServiceGroup.svelte';
|
||||||
import type { PageData } from './$types';
|
import type { PageData } from './$types';
|
||||||
|
|
||||||
export let data: PageData;
|
export let data: PageData;
|
||||||
@@ -9,19 +10,6 @@
|
|||||||
<h2>{data.config.subtitle}</h2>
|
<h2>{data.config.subtitle}</h2>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<ul>
|
{#each data.config.services as group, i}
|
||||||
{#each data.config.services as group, i}
|
<ServiceGroup {group} groupData={data.serviceData[i]} />
|
||||||
<li>
|
{/each}
|
||||||
<p>{group.title}</p>
|
|
||||||
<ul>
|
|
||||||
{#each group.items as service, j}
|
|
||||||
<li>
|
|
||||||
{i},{j}
|
|
||||||
<pre> {JSON.stringify(service)}</pre>
|
|
||||||
<pre> {JSON.stringify(data.serviceData[i][j])}</pre>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
</li>
|
|
||||||
{/each}
|
|
||||||
</ul>
|
|
||||||
|
|||||||
Reference in New Issue
Block a user