From ddd236af06963da77386e1c1060daddd4bbb0e3d Mon Sep 17 00:00:00 2001 From: Mario Linz Date: Thu, 9 Jun 2022 15:06:16 +0200 Subject: [PATCH] =?UTF-8?q?Vereinheitlichen=20der=20API=20Parameter=20f?= =?UTF-8?q?=C3=BCr=20Articles=20und=20Content=20Api=20Methoden.=20Interfac?= =?UTF-8?q?es=20etwas=20angepasst.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api.ts | 5 ++--- src/components/routes/Content.svelte | 6 ++++-- src/components/widgets/LanguageChooser.svelte | 3 +-- src/components/widgets/TibiArticleMediaFile.svelte | 4 +--- types/global.d.ts | 9 ++------- 5 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/api.ts b/src/api.ts index 630355e..1f48326 100644 --- a/src/api.ts +++ b/src/api.ts @@ -186,12 +186,11 @@ export const sendEmail = async (type: string = "contactForm", data: any, noToken }) } -export const getContent = async (filter: APIParams, params?: APIParams): Promise => { +export const getContent = async (apiParams: APIParams): Promise => { const c = await api("content", { // limit: 1, - params, - filter, sort: "-priority", + ...apiParams, }) if (c?.data?.length) { diff --git a/src/components/routes/Content.svelte b/src/components/routes/Content.svelte index 34afba8..a69cb66 100644 --- a/src/components/routes/Content.svelte +++ b/src/components/routes/Content.svelte @@ -11,7 +11,6 @@ let loading = true let content: Content let connectedContentNotFound: boolean = false - let oldLocation: string $: currentDomain = window.location.protocol + "//" + window.location.host const load = (type?: string) => { @@ -36,8 +35,11 @@ } // Get content by API call + let apiParams: APIParams = { + filter, + } loading = true - getContent(filter) + getContent(apiParams) .then((c) => { if (c) { if (type === "changedLanguage") { diff --git a/src/components/widgets/LanguageChooser.svelte b/src/components/widgets/LanguageChooser.svelte index bb3616e..0987fb8 100644 --- a/src/components/widgets/LanguageChooser.svelte +++ b/src/components/widgets/LanguageChooser.svelte @@ -1,7 +1,6 @@ diff --git a/types/global.d.ts b/types/global.d.ts index 6e24af7..f9263a3 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -16,13 +16,7 @@ interface CollectionEntry { } interface ContentBlock { - layout: 1 | 2 | 3 | 4 - title?: string - subtitle?: string - text?: string - button_text?: string - button_url?: string - images?: ImageEntry[] + article: any } interface Content { @@ -30,6 +24,7 @@ interface Content { locale: string tags?: string[] path: string + name: string blocks: ContentBlock[] }