Vereinheitlichen der API Parameter für Articles und Content Api Methoden. Interfaces etwas angepasst.

This commit is contained in:
Mario Linz 2022-06-09 15:06:16 +02:00
parent 9cf3a814e3
commit ddd236af06
5 changed files with 10 additions and 17 deletions

View File

@ -186,12 +186,11 @@ export const sendEmail = async (type: string = "contactForm", data: any, noToken
}) })
} }
export const getContent = async (filter: APIParams, params?: APIParams): Promise<Content> => { export const getContent = async (apiParams: APIParams): Promise<Content> => {
const c = await api<Content[]>("content", { const c = await api<Content[]>("content", {
// limit: 1, // limit: 1,
params,
filter,
sort: "-priority", sort: "-priority",
...apiParams,
}) })
if (c?.data?.length) { if (c?.data?.length) {

View File

@ -11,7 +11,6 @@
let loading = true let loading = true
let content: Content let content: Content
let connectedContentNotFound: boolean = false let connectedContentNotFound: boolean = false
let oldLocation: string
$: currentDomain = window.location.protocol + "//" + window.location.host $: currentDomain = window.location.protocol + "//" + window.location.host
const load = (type?: string) => { const load = (type?: string) => {
@ -36,8 +35,11 @@
} }
// Get content by API call // Get content by API call
let apiParams: APIParams = {
filter,
}
loading = true loading = true
getContent(filter) getContent(apiParams)
.then((c) => { .then((c) => {
if (c) { if (c) {
if (type === "changedLanguage") { if (type === "changedLanguage") {

View File

@ -1,7 +1,6 @@
<script lang="ts"> <script lang="ts">
import { locale } from "svelte-i18n" import { locale } from "svelte-i18n"
import { navigate } from "svelte-routing" import { navigations, currentLang } from "../../store"
import { navigations, location, currentLang } from "../../store"
$: languages = [] $: languages = []

View File

@ -1,11 +1,9 @@
<script lang="ts"> <script lang="ts">
import { apiBaseURL } from "../../config"
import Image from "./Image.svelte" import Image from "./Image.svelte"
export let collectionName: string = null export let collectionName: string = null
export let entryId: string = null export let entryId: string = null
export let mediaFile: TibiArticleImage = null export let mediaFile: TibiArticleMediaFile = null
export let cssClass: string = "" export let cssClass: string = ""
</script> </script>

9
types/global.d.ts vendored
View File

@ -16,13 +16,7 @@ interface CollectionEntry {
} }
interface ContentBlock { interface ContentBlock {
layout: 1 | 2 | 3 | 4 article: any
title?: string
subtitle?: string
text?: string
button_text?: string
button_url?: string
images?: ImageEntry[]
} }
interface Content { interface Content {
@ -30,6 +24,7 @@ interface Content {
locale: string locale: string
tags?: string[] tags?: string[]
path: string path: string
name: string
blocks: ContentBlock[] blocks: ContentBlock[]
} }