Konfiguration von Seiten-Verknüpfungen nach Gespräch mit Marc geändert.

This commit is contained in:
Mario Linz 2022-06-16 09:48:18 +02:00
parent 706ec88576
commit d8e4f9c902
10 changed files with 197 additions and 103 deletions

View File

@ -38,21 +38,21 @@ meta:
- source: article.general.locale
type: flag
# Filter Navigation-Items in Collection-Navigation
navigationFilter:
- label: { de: "News", en: "News" }
mdiIcon: filter-outline
params:
- sort: article.general.sort
# - s.article.general.public: true
- w.article.content.title: lor
- s.article.general.locale: de
- label: { de: "Diam", en: "Diam" }
mdiIcon: filter-outline
params:
- sort: article.general.sort
- s.article.general.public: true
- w.article.content.title: diam
- s.article.general.locale: de
# navigationFilter:
# - label: { de: "News", en: "News" }
# mdiIcon: filter-outline
# params:
# - sort: article.general.sort
# # - s.article.general.public: true
# - w.article.content.title: lor
# - s.article.general.locale: de
# - label: { de: "Diam", en: "Diam" }
# mdiIcon: filter-outline
# params:
# - sort: article.general.sort
# - s.article.general.public: true
# - w.article.content.title: diam
# - s.article.general.locale: de
imageFilter:
xs:

View File

@ -55,6 +55,12 @@ meta:
source: meta
subFields:
- source: meta
- name: assignments
meta:
label: { de: "Verknüpfungen", en: "Assignments" }
source: meta
subFields:
- source: pages
imageFilter:
xs:
@ -135,13 +141,32 @@ fields:
de: "Der Pfad muss eindeutig sein und ohne ein Slash (/) beginnen und enden."
en: "The path must be unique and must start and end without a slash (/)."
- !include fields/_locale.yml
- name: pages
type: string[]
meta:
hideInRoot: true
helperText:
de: "Verknüpft Seiten mit beliebigen anderen Seiten."
en: "Links the page to any other page."
widget: chipArray
label:
de: Verknüpfung zu Seiten
en: Assignment to pages
defaultValue: []
choices:
endpoint: "content"
mapping:
id: "id"
name: "path"
params:
sort: "path"
- name: tags
type: string[]
meta:
hideInRoot: true
helperText:
de: "Seiten können miteinander verknüpft werden. Entsprechende Seiten in einer anderen Sprache, die mit den selben zugewiesenen Schlagworten gekennzeichnet sind, können bei Umschaltung der Seitensprache gefunden werden. Wählen Sie einen existierenden Eintrag aus der Liste oder geben Sie ein neues Schlagwort ein und bestätigen mit Enter."
en: "Pages can be linked together. Corresponding pages in another language, marked with the same assigned keywords, can be found by switching the page language. Select an existing entry from the list or enter a new keyword and confirm with Enter."
de: "Über die Zuweisung von Schlagworten, können Seiten noch einmal genauer kategorisiert werden."
en: "Pages can be categorized more precisely by assigning keywords."
widget: chipArray
label:
de: Schlagwort / Tag / Label

View File

@ -0,0 +1,60 @@
name: assignments
type: object
meta:
label: { de: "Verknüpfung", en: "Assignment" }
subFields:
- name: pages
type: string[]
meta:
helperText:
de: "Verknüpft den Artikel mit beliebigen Seiten."
en: "Links the article to any page."
widget: chipArray
label:
de: Verknüpfung zu Seiten
en: Assignment to pages
defaultValue: []
choices:
endpoint: "content"
mapping:
id: "path"
name: "path"
params:
sort: "path"
- name: articles
type: string[]
meta:
helperText:
de: "Verknüpft den Artikel mit beliebigen Artikeln."
en: "Links the article to any articles."
widget: chipArray
label:
de: Verknüpfung zu Artikeln
en: Assignment to articles
defaultValue: []
choices:
endpoint: "articles"
mapping:
id: "id"
name: "title"
params:
sort: "title"
- name: tags
type: string[]
meta:
helperText:
de: "Über die Zuweisung von Schlagworten, können Artikel noch einmal genauer kategorisiert werden."
en: "Articles can be categorized more precisely by assigning keywords."
widget: chipArray
label:
de: Tags / Schlagworte / Labels
en: Tags
addAllowed: true
defaultValue: []
choices:
endpoint: "tags"
mapping:
id: "name"
name: "name"
params:
sort: "name"

View File

@ -40,43 +40,6 @@ subFields:
- { id: "default", name: { de: "Artikel", en: "Article" } }
- { id: "news", name: { de: "News", en: "News" } }
- !include ../_locale.yml
- name: tags
type: string[]
meta:
helperText:
de: "Über die Zuweisung von Schlagworten, können Artikel kategorisiert werden."
en: "Articles can be categorized by assigning keywords."
widget: chipArray
label:
de: Schlagworte / Tags / Labels
en: Linking Tags
addAllowed: true
defaultValue: []
choices:
endpoint: "tags"
mapping:
id: "name"
name: "name"
params:
sort: "name"
- name: pages
type: string[]
meta:
helperText:
de: "Zuordnung zu Seiten"
en: "Assignment to Pages"
widget: chipArray
label:
de: Seiten
en: Pages
defaultValue: []
choices:
endpoint: "content"
mapping:
id: "path"
name: "path"
params:
sort: "path"
- name: publish_date
type: object
meta:
@ -151,7 +114,7 @@ subFields:
label:
de: Inhalt dieses Artikel
en: Article Content
activeTab: 2
activeTab: 0
subFields:
- name: teaser
type: string
@ -194,3 +157,4 @@ subFields:
- !include _article-layout-margin.yml
- !include _article-layout-padding.yml
- !include _article-link.yml
- !include _article-assignments.yml

View File

@ -141,12 +141,23 @@ x-url: &url
meta:
widget: select
label: { de: Zielfenster, en: Target }
defaultValue: "_self"
defaultValue: "default"
choices:
- { id: "default", name: "Gleicher Tab oder Seite (ohne Refresh)" }
- { id: "_self", name: "Gleicher Tab oder Seite (Standardwert)" }
- { id: "_blank", name: "Neuer Tab oder Fenster" }
- { id: "_parent", name: "Elternfenster" }
- name: hidden
type: boolean
meta:
label: { de: "Ausgeblendet", en: "Hidden" }
helperText:
{
de: "Definiert, ob der Navigationspunkt in der Navigation angezeigt werden soll oder nicht.",
en: "Defines whether the navigation point should be displayed in the navigation or not.",
}
x-items: &items
name: items
type: object[]

View File

@ -4,7 +4,6 @@
import { generalInfo, currentLang, location } from "../../store"
import { navigate } from "svelte-routing"
import Image from "../widgets/Image.svelte"
import ArticlesList from "../widgets/ArticlesList.svelte"
import ArticleDetails from "../routes/ArticleDetails.svelte"
@ -14,7 +13,6 @@
let content: Content
let article: TibiArticle
let connectedContentNotFound: boolean = false
$: currentDomain = window.location.protocol + "//" + window.location.host
const loadContent = (type?: string) => {
// Set default API call filter
@ -29,9 +27,9 @@
}
// Changed filter to find simmilar content for changed language
if (type === "changedLanguage" && content?.tags) {
if (type === "changedLanguage" && content?.pages) {
filter = {
tags: { $in: content?.tags },
_id: { $in: content?.pages },
locale: $currentLang,
}
delete filter.path
@ -118,6 +116,12 @@
content = null
article = null
// Update current language when lang in URL not equal to current language
let pathParts = window.location.pathname.split("/")
if (pathParts.length > 3 && $currentLang !== pathParts[1]) {
$currentLang = pathParts[1]
}
if (window.location.pathname.endsWith("/")) {
loadContent()
} else {

View File

@ -39,9 +39,9 @@
{/if}
</svelte:head>
<ArticlesList tags="{['home']}" />
<ArticlesList pages="{['/']}" />
<GeneralMediaImage id="test1" />
<!-- <GeneralMediaImage id="test1" /> -->
<!-- <ContactForm type="recipe" collapsed="{expandedForm !== 'recipe'}" /> -->
<!-- <ContactForm type="contact" collapsed="{expandedForm !== 'contact'}" /> -->

View File

@ -5,6 +5,7 @@
import Article from "../widgets/Article.svelte"
export let tags: string[] = null
export let pages: string[] = null
export let path: string = null
let articleEntries: CollectionEntry[] = []
@ -15,11 +16,15 @@
}
if (tags && tags?.length) {
filter["article.general.tags"] = { $in: tags }
filter["article.assignments.tags"] = { $in: tags }
}
if (pages && pages?.length) {
filter["article.assignments.pages"] = { $in: pages }
}
if (path) {
filter["article.general.pages"] = { $in: [path] }
filter["article.assignments.pages"] = { $in: [path] }
}
getArticles("articles", { filter }).then((response) => {

View File

@ -3,7 +3,7 @@
import Icon from "mdi-svelte"
import { mdiMenu } from "@mdi/js"
import { links } from "svelte-routing"
import { links, link } from "svelte-routing"
import { navigations, currentLang, location } from "../../store"
import LanguageChooser from "./LanguageChooser.svelte"
@ -28,21 +28,33 @@
{#if navigation}
<nav class="{ident}" use:links>
{#each navigation?.items || [] as item}
{#if item.settings.url.url}
<a
href="{item.settings.url.url}"
target="{item.settings.url.target}"
on:click="{() => {
animateScroll.scrollTo({ element: item.settings.url.url, offset: -200 })
showMobileNav = false
}}"
>
{item.settings.title}
</a>
{:else}
<a href="{item.settings.page + '/'}" class:active="{'/' + item.settings.page === $location.path}">
{item.settings.title}
</a>
{#if !item.settings.url.hidden}
{#if item.settings.url.url}
{#if item.settings.url.target === "default"}
<a
use:link
href="{item.settings.url.url}"
class:active="{'/' + item.settings.page === $location.path}"
>
{item.settings.title}
</a>
{:else}
<a
href="{item.settings.url.url}"
target="{item.settings.url.target}"
on:click="{() => {
animateScroll.scrollTo({ element: item.settings.url.url, offset: -200 })
showMobileNav = false
}}"
>
{item.settings.title}
</a>
{/if}
{:else}
<a href="{item.settings.page + '/'}" class:active="{'/' + item.settings.page === $location.path}">
{item.settings.title}
</a>
{/if}
{/if}
{/each}
</nav>
@ -54,29 +66,41 @@
<nav class="{ident}-mobile" class:show="{showMobileNav}" use:links>
{#each navigation?.items || [] as item}
{#if item.settings.url.url}
<div class="nav-item">
<a
href="{item.settings.url.url}"
target="{item.settings.url.target}"
on:click="{() => {
animateScroll.scrollTo({ element: item.settings.url.url, offset: -200 })
showMobileNav = false
}}"
>
{item.settings.title}
</a>
</div>
{:else}
<div class="nav-item">
<a
href="{item.settings.page + '/'}"
on:click="{() => (showMobileNav = false)}"
class:active="{'/' + item.settings.page === $location.path}"
>
{item.settings.title}
</a>
</div>
{#if !item.settings.url.hidden}
{#if item.settings.url.url}
{#if item.settings.url.target === "default"}
<a
use:link
href="{item.settings.url.url}"
class:active="{'/' + item.settings.page === $location.path}"
>
{item.settings.title}
</a>
{:else}
<div class="nav-item">
<a
href="{item.settings.url.url}"
target="{item.settings.url.target}"
on:click="{() => {
animateScroll.scrollTo({ element: item.settings.url.url, offset: -200 })
showMobileNav = false
}}"
>
{item.settings.title}
</a>
</div>
{/if}
{:else}
<div class="nav-item">
<a
href="{item.settings.page + '/'}"
on:click="{() => (showMobileNav = false)}"
class:active="{'/' + item.settings.page === $location.path}"
>
{item.settings.title}
</a>
</div>
{/if}
{/if}
{/each}
</nav>

1
types/global.d.ts vendored
View File

@ -166,6 +166,7 @@ interface NavigationItem {
url: {
url: string
target: string
hidden: boolean
}
}
}