Template
Content-Seiten und Language Chooser + Collections so überarbeitet, dass ein Umschalten zwischen Sprachen und Pages möglich ist. Collection der Seiten wurde um eine Priorität erweitert. Navigation zeigt aktives Item an. Entsprechende CSS Klassen angepasst und für neue Projekte sauberer strukturiert.
This commit is contained in:
1 parent
fcf5490d5a
commit
87aa1689f3
8 files changed
+162
-109
No files matched your search
@@ -1,6 +1,7 @@
|
||||
<script lang="ts">
|
||||
import { getContent } from "../../api"
|
||||
import { generalInfo, currentLang } from "../../store"
|
||||
import { generalInfo, currentLang, location } from "../../store"
|
||||
import { navigate } from "svelte-routing"
|
||||
|
||||
import Image from "../widgets/Image.svelte"
|
||||
|
||||
@@ -9,19 +10,30 @@
|
||||
let loading = true
|
||||
let content: Content
|
||||
let currentDomain = window.location.protocol + "//" + window.location.host
|
||||
let oldLocation: string
|
||||
|
||||
const load = () => {
|
||||
let filter = {}
|
||||
if (content?.tags) {
|
||||
const load = (type?: string) => {
|
||||
let filter = {
|
||||
path,
|
||||
}
|
||||
|
||||
if (type === "changedLanguage" && content?.tags) {
|
||||
filter = {
|
||||
tags: { $in: content?.tags },
|
||||
}
|
||||
delete filter.path
|
||||
}
|
||||
|
||||
loading = true
|
||||
getContent(path, $currentLang, filter)
|
||||
getContent($currentLang, filter)
|
||||
.then((c) => {
|
||||
content = c
|
||||
if (c && c.length) {
|
||||
if (type === "changedLanguage") {
|
||||
navigate("/" + c[0].path + $location.search, { replace: true })
|
||||
} else {
|
||||
content = c[0]
|
||||
}
|
||||
}
|
||||
})
|
||||
.finally(() => {
|
||||
loading = false
|
||||
@@ -29,7 +41,7 @@
|
||||
}
|
||||
|
||||
currentLang.subscribe(() => {
|
||||
load()
|
||||
load("changedLanguage")
|
||||
})
|
||||
|
||||
$: if (path) load()
|
||||
@@ -46,6 +58,7 @@
|
||||
<!-- Loader -->
|
||||
{:else if content}
|
||||
{#each content.blocks || [] as b}
|
||||
<h1>{b.article.content.title}</h1>
|
||||
{JSON.stringify(b)}
|
||||
{/each}
|
||||
{:else}
|
||||
|
||||
@@ -17,8 +17,6 @@
|
||||
|
||||
const setLanguage = (lang: string) => {
|
||||
$currentLang = lang
|
||||
// $location.path = "/" + lang
|
||||
// navigate($location.path + $location.search, { replace: true })
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@
|
||||
{item.settings.title}
|
||||
</a>
|
||||
{:else}
|
||||
<a href="{item.settings.page}" class:active="{item.settings.page === $location.path}">
|
||||
<a href="{item.settings.page}" class:active="{'/' + item.settings.page === $location.path}">
|
||||
{item.settings.title}
|
||||
</a>
|
||||
{/if}
|
||||
@@ -72,7 +72,7 @@
|
||||
<a
|
||||
href="{item.settings.page}"
|
||||
on:click="{() => (showMobileNav = false)}"
|
||||
class:active="{item.settings.page === $location.path}"
|
||||
class:active="{'/' + item.settings.page === $location.path}"
|
||||
>
|
||||
{item.settings.title}
|
||||
</a>
|
||||
|
||||
Reference in new issue
Block a user