forked from cms/tibi-svelte-starter
Content Collection um Tags ChipArray erweitert, um eine Möglichkeit zu schaffen, Stichworte zum Verknüpfen der Seiten zwischen den Sprachen zu schaffen...(WIP)
This commit is contained in:
parent
5d08a96327
commit
fcf5490d5a
@ -107,6 +107,24 @@ hooks:
|
|||||||
# Feldliste der Kollektion
|
# Feldliste der Kollektion
|
||||||
fields:
|
fields:
|
||||||
- !include fields/_locale.yml
|
- !include fields/_locale.yml
|
||||||
|
- name: tags
|
||||||
|
type: string[]
|
||||||
|
meta:
|
||||||
|
helperText:
|
||||||
|
de: "Entsprechende Seiten in einer anderen Sprache, die mit den selben zugewiesenen Stichworten gekennzeichnet sind, können bei Umschaltung der Seitensprache gefunden werden."
|
||||||
|
en: ""
|
||||||
|
widget: chipArray
|
||||||
|
label:
|
||||||
|
de: Verknüpfungs-Stichworte
|
||||||
|
en: Linking Tags
|
||||||
|
defaultValue: []
|
||||||
|
choices:
|
||||||
|
endpoint: "tags"
|
||||||
|
mapping:
|
||||||
|
id: "id"
|
||||||
|
name: "name"
|
||||||
|
params:
|
||||||
|
sort: "name"
|
||||||
- name: path
|
- name: path
|
||||||
type: string
|
type: string
|
||||||
index: [single, unique]
|
index: [single, unique]
|
||||||
|
@ -186,10 +186,10 @@ export const sendEmail = async (type: string = "contactForm", data: any, noToken
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getContent = async (path: string, lang: string): Promise<Content> => {
|
export const getContent = async (path: string, lang: string, filter?: APIParams): Promise<Content> => {
|
||||||
const c = await api<Content[]>("content", {
|
const c = await api<Content[]>("content", {
|
||||||
limit: 1,
|
limit: 1,
|
||||||
filter: { path, locale: lang },
|
filter: { path, locale: lang, ...filter },
|
||||||
})
|
})
|
||||||
if (c?.data?.length) {
|
if (c?.data?.length) {
|
||||||
return c.data[0]
|
return c.data[0]
|
||||||
|
@ -11,8 +11,15 @@
|
|||||||
let currentDomain = window.location.protocol + "//" + window.location.host
|
let currentDomain = window.location.protocol + "//" + window.location.host
|
||||||
|
|
||||||
const load = () => {
|
const load = () => {
|
||||||
|
let filter = {}
|
||||||
|
if (content?.tags) {
|
||||||
|
filter = {
|
||||||
|
tags: { $in: content?.tags },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
loading = true
|
loading = true
|
||||||
getContent(path, $currentLang)
|
getContent(path, $currentLang, filter)
|
||||||
.then((c) => {
|
.then((c) => {
|
||||||
content = c
|
content = c
|
||||||
})
|
})
|
||||||
@ -31,7 +38,7 @@
|
|||||||
<svelte:head>
|
<svelte:head>
|
||||||
<title>{content?.name ? content?.name + " - " : ""}{$generalInfo?.meta?.metaTitle}</title>
|
<title>{content?.name ? content?.name + " - " : ""}{$generalInfo?.meta?.metaTitle}</title>
|
||||||
</svelte:head>
|
</svelte:head>
|
||||||
{path}
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
|
@ -4,13 +4,15 @@
|
|||||||
|
|
||||||
$: languages = []
|
$: languages = []
|
||||||
|
|
||||||
$: if ($navigations?.length) {
|
$: {
|
||||||
$navigations.forEach((nav) => {
|
if ($navigations?.length) {
|
||||||
if (!languages.includes(nav.locale)) {
|
$navigations.forEach((nav) => {
|
||||||
languages.push(nav.locale)
|
if (!languages.includes(nav.locale)) {
|
||||||
}
|
languages.push(nav.locale)
|
||||||
})
|
}
|
||||||
languages = languages
|
})
|
||||||
|
languages = languages
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const setLanguage = (lang: string) => {
|
const setLanguage = (lang: string) => {
|
||||||
|
3
types/global.d.ts
vendored
3
types/global.d.ts
vendored
@ -19,7 +19,8 @@ interface ContentBlock {
|
|||||||
|
|
||||||
interface Content {
|
interface Content {
|
||||||
id: string
|
id: string
|
||||||
name: string
|
locale: string
|
||||||
|
tags?: string[]
|
||||||
path: string
|
path: string
|
||||||
blocks: ContentBlock[]
|
blocks: ContentBlock[]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user