Article-Collection etwas aufgeräumt und in einzelne Files ausgelagert.

This commit is contained in:
2022-06-09 14:24:32 +02:00
parent de6968f3d8
commit 9cf3a814e3
10 changed files with 290 additions and 221 deletions

View File

@@ -217,21 +217,16 @@ export const getGeneralInformation = async (): Promise<GeneralInfo[]> => {
}
}
export const getArticles = async (
collectionName: string,
filter: APIParams,
params?: APIParams
): Promise<TibiArticle[]> => {
export const getArticles = async (collectionName: string, apiParams: APIParams): Promise<TibiArticle[]> => {
try {
let response = await api<TibiArticle[]>(collectionName, {
method: "get",
offset: 0,
params,
filter: {
"article.general.public": true,
...filter,
},
sort: "article.general.sort",
...apiParams,
})
return response.data
} catch (e) {

View File

@@ -0,0 +1,24 @@
<script lang="ts">
import { currentLang } from "../../store"
import { getArticles } from "../../api"
// import Article from "../widgets/Article.svelte"
$: if ($currentLang) {
getArticles("articles", {
filter: {
"article.general.locale": $currentLang,
},
}).then((response) => {
console.log(response)
})
}
</script>
<div class="container">
<div class="row">
<div class="col-md-12">
<h1>ARTICLE DETAILS</h1>
</div>
</div>
</div>

View File

@@ -1,7 +1,7 @@
<script lang="ts">
import * as animateScroll from "svelte-scrollto"
import { generalInfo, currentLang } from "../../store"
import { currentLang } from "../../store"
import { getArticles } from "../../api"
import GoogleMaps from "../widgets/GoogleMaps.svelte"
@@ -15,7 +15,9 @@
$: if ($currentLang) {
getArticles("articles", {
"article.general.locale": $currentLang,
filter: {
"article.general.locale": $currentLang,
},
}).then((response) => {
articleEntries = response
})