Zuweisung von Artikeln zu Seiten möglich. Somit werden keine Content-Blocks mehr benötigt und alle Artikel können über die articles-Collection gepflegt udn zugewiesen werden.

This commit is contained in:
Mario Linz 2022-06-14 10:30:40 +02:00
parent 05fe698af6
commit ee7ed0db1f
8 changed files with 42 additions and 30 deletions

View File

@ -141,10 +141,10 @@ fields:
helperText:
de: "Sind mehr als ein Stichwort mit einer Seite verknüpft, führt die Priorität (z.B.: eine Zahl von 0..10..x) der gefundenen Seiten zu einer automatischen Vorauswahl aus den gefundenen Seiten."
en: "If more than one keyword is linked to a page, the priority (e.g. a number 0..10..x) of the pages found leads to an automatic preselection from the pages found."
- name: blocks
type: object[]
meta:
label: { de: "Artikel dieser Seite", en: "Page Articles" }
collapse: { titleFieldName: "article.content.title" }
subFields:
- !include fields/_article.yml
# - name: blocks
# type: object[]
# meta:
# label: { de: "Artikel dieser Seite", en: "Page Articles" }
# collapse: { titleFieldName: "article.content.title" }
# subFields:
# - !include fields/_article.yml

View File

@ -58,7 +58,7 @@ subFields:
choices:
endpoint: "content"
mapping:
id: "id"
id: "path"
name: "path"
params:
sort: "path"

View File

@ -5,6 +5,8 @@
import { navigate } from "svelte-routing"
import Image from "../widgets/Image.svelte"
import ArticlesList from "../widgets/ArticlesList.svelte"
// import Article from "../widgets/Article.svelte"
export let path: string
@ -13,7 +15,7 @@
let connectedContentNotFound: boolean = false
$: currentDomain = window.location.protocol + "//" + window.location.host
const load = (type?: string) => {
const loadContent = (type?: string) => {
// Set default API call filter
let filter = {
locale: $currentLang,
@ -45,6 +47,7 @@
if (type === "changedLanguage") {
let newPath = c.path + $location.search
window.history.pushState({}, document.getElementsByTagName("title")[0].innerHTML, newPath)
path = newPath
}
connectedContentNotFound = false
@ -69,11 +72,11 @@
currentLang.subscribe(() => {
if (content) {
load("changedLanguage")
loadContent("changedLanguage")
}
})
$: if (path) load()
$: if (path) loadContent()
</script>
<svelte:head>
@ -86,11 +89,12 @@
{#if loading}
<!-- Loader -->
{:else if content}
<!-- {JSON.stringify(content)} -->
<!--
{#each content.blocks || [] as b}
<h1>{b.article.content.title}</h1>
{JSON.stringify(b)}
{/each}
-->
<ArticlesList path="{path}" />
{:else}
<div class="page-404">
<div>

View File

@ -1,14 +1,10 @@
<script lang="ts">
import * as animateScroll from "svelte-scrollto"
import { currentLang } from "../../store"
import { getArticles } from "../../api"
import GoogleMaps from "../widgets/GoogleMaps.svelte"
import ScrollTo from "../widgets/ScrollTo.svelte"
import ContactForm from "../widgets/ContactForm.svelte"
import GeneralMediaImage from "../widgets/GeneralMediaImage.svelte"
import Article from "../widgets/Article.svelte"
import ArticlesList from "../widgets/ArticlesList.svelte"
let expandedForm: string = "recipe"

View File

@ -4,11 +4,15 @@
import TibiArticleMediaFile from "./TibiArticleMediaFile.svelte"
export let entry: CollectionEntry
export let entry: CollectionEntry = null
export let cssClass: string = ""
export let showDetails: boolean = false
let article = entry.article
let article = null
if (entry) {
article = entry.article
}
let marginClasses: string = ""
let paddingClasses: string = ""
let published: boolean = true
@ -61,7 +65,7 @@
</script>
{#if article && published}
<article class="{cssClass} {article?.layout?.variant} {marginClasses} {paddingClasses}" transition:fade>
<article class="{cssClass} {article?.layout?.variant} {marginClasses} {paddingClasses}">
{#if article?.layout?.variant === "top"}
{#if article?.content?.types?.media?.files?.length}
<TibiArticleMediaFile

View File

@ -4,17 +4,25 @@
import Article from "../widgets/Article.svelte"
export let tag: string
export let tag: string = null
export let path: string = null
let articleEntries: CollectionEntry[] = []
$: if ($currentLang) {
getArticles("articles", {
filter: {
"article.general.locale": $currentLang,
"article.general.tags": { $in: [tag] },
},
}).then((response) => {
let filter = {
"article.general.locale": $currentLang,
}
if (tag) {
filter["article.general.tags"] = { $in: [tag] }
}
if (path) {
filter["article.general.pages"] = { $in: [path] }
}
getArticles("articles", { filter }).then((response) => {
articleEntries = response
})
}

View File

@ -1,7 +1,7 @@
article,
.article {
overflow-wrap: anywhere;
border: 1px dashed @on-background;
// border: 1px dashed @on-background;
& ~ article,
& ~ .article {

4
types/global.d.ts vendored
View File

@ -27,7 +27,7 @@ interface Content {
tags?: string[]
path: string
name: string
blocks: ContentBlock[]
blocks?: ContentBlock[]
}
interface GeneralInfo {
@ -68,7 +68,7 @@ interface GeneralInfo {
}
interface TibiArticle {
id: string
id?: string
article: {
general: {
public: boolean