forked from cms/tibi-svelte-starter
Typ Select für Artikel hinzugefügt. Artikel-Details Komponenten sind nun für jeden Typ verfügbar, wenn benötigt.
This commit is contained in:
parent
652f15830d
commit
0d06a61c7f
@ -21,6 +21,7 @@ meta:
|
|||||||
columns:
|
columns:
|
||||||
- article.general.public
|
- article.general.public
|
||||||
- article.content.title
|
- article.content.title
|
||||||
|
- article.general.type
|
||||||
- article.general.sort
|
- article.general.sort
|
||||||
- source: article.general.locale
|
- source: article.general.locale
|
||||||
type: flag
|
type: flag
|
||||||
@ -32,6 +33,7 @@ meta:
|
|||||||
- label: { de: "Titel", en: "Title" }
|
- label: { de: "Titel", en: "Title" }
|
||||||
source: article.content.title
|
source: article.content.title
|
||||||
filter: true
|
filter: true
|
||||||
|
- article.general.type
|
||||||
- article.general.sort
|
- article.general.sort
|
||||||
- source: article.general.locale
|
- source: article.general.locale
|
||||||
type: flag
|
type: flag
|
||||||
|
@ -24,6 +24,21 @@ subFields:
|
|||||||
helperText:
|
helperText:
|
||||||
de: "Der Artikel wird auf der Seite angezeigt."
|
de: "Der Artikel wird auf der Seite angezeigt."
|
||||||
en: "This article is displayed on the page."
|
en: "This article is displayed on the page."
|
||||||
|
- name: type
|
||||||
|
type: string
|
||||||
|
meta:
|
||||||
|
filter: true
|
||||||
|
helperText:
|
||||||
|
de: "Definiert allgemeinen Typ des Artikels."
|
||||||
|
en: "Defines general type of the article."
|
||||||
|
widget: select
|
||||||
|
label:
|
||||||
|
de: Typ des Artikels
|
||||||
|
en: Article type
|
||||||
|
defaultValue: default
|
||||||
|
choices:
|
||||||
|
- { id: "default", name: { de: "Artikel", en: "Article" } }
|
||||||
|
- { id: "news", name: { de: "News", en: "News" } }
|
||||||
- !include ../_locale.yml
|
- !include ../_locale.yml
|
||||||
- name: tags
|
- name: tags
|
||||||
type: string[]
|
type: string[]
|
||||||
@ -158,10 +173,13 @@ subFields:
|
|||||||
- name: variant
|
- name: variant
|
||||||
type: string
|
type: string
|
||||||
meta:
|
meta:
|
||||||
|
helperText:
|
||||||
|
de: "Definiert das visuelle Erscheinungsbild der aller Teaser-Informationen des Artikels."
|
||||||
|
en: "Defines the visual appearance of all teaser information of the article."
|
||||||
widget: select
|
widget: select
|
||||||
label:
|
label:
|
||||||
de: Erscheinungsbild
|
de: Teaser Erscheinungsbild
|
||||||
en: Appearance
|
en: Teaser Layout
|
||||||
defaultValue: default
|
defaultValue: default
|
||||||
choices:
|
choices:
|
||||||
- { id: "top", name: { de: "Artikelbild oben", en: "Article picture top" } }
|
- { id: "top", name: { de: "Artikelbild oben", en: "Article picture top" } }
|
||||||
|
@ -1,34 +1,9 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { currentLang } from "../../store"
|
import details from "./../widgets/details"
|
||||||
import { getArticles } from "../../api"
|
|
||||||
|
|
||||||
import Article from "../widgets/Article.svelte"
|
export let entry: TibiArticle
|
||||||
|
|
||||||
export let path: string
|
|
||||||
|
|
||||||
let articleEntries: CollectionEntry[] = []
|
|
||||||
|
|
||||||
$: if ($currentLang) {
|
|
||||||
let urlParts = path.split("/")
|
|
||||||
let slug = urlParts[urlParts.length - 1]
|
|
||||||
|
|
||||||
getArticles("articles", {
|
|
||||||
filter: {
|
|
||||||
"article.general.locale": $currentLang,
|
|
||||||
"article.content.slug": slug,
|
|
||||||
},
|
|
||||||
}).then((response) => {
|
|
||||||
articleEntries = response
|
|
||||||
})
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">
|
{#if entry}
|
||||||
<div class="row">
|
<svelte:component this="{details[entry?.article?.general?.type] || details.default}" entry="{entry}" />
|
||||||
<div class="col-md-12">
|
{/if}
|
||||||
{#each articleEntries || [] as entry}
|
|
||||||
<Article entry="{entry}" />
|
|
||||||
{/each}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
@ -6,10 +6,9 @@
|
|||||||
|
|
||||||
import Image from "../widgets/Image.svelte"
|
import Image from "../widgets/Image.svelte"
|
||||||
import ArticlesList from "../widgets/ArticlesList.svelte"
|
import ArticlesList from "../widgets/ArticlesList.svelte"
|
||||||
import Article from "../widgets/Article.svelte"
|
import ArticleDetails from "../routes/ArticleDetails.svelte"
|
||||||
|
|
||||||
export let path: string
|
export let path: string
|
||||||
let oldPath: string = null
|
|
||||||
|
|
||||||
let loading = true
|
let loading = true
|
||||||
let content: Content
|
let content: Content
|
||||||
@ -63,8 +62,6 @@
|
|||||||
content = null
|
content = null
|
||||||
}
|
}
|
||||||
|
|
||||||
oldPath = path
|
|
||||||
|
|
||||||
// Redirect to HOME if no content has been found. So the page 404 content will never shown.
|
// Redirect to HOME if no content has been found. So the page 404 content will never shown.
|
||||||
if (!content) {
|
if (!content) {
|
||||||
navigate("/")
|
navigate("/")
|
||||||
@ -103,7 +100,6 @@
|
|||||||
getArticles("articles", apiParams)
|
getArticles("articles", apiParams)
|
||||||
.then((respoonse) => {
|
.then((respoonse) => {
|
||||||
article = respoonse[0]
|
article = respoonse[0]
|
||||||
oldPath = path
|
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
loading = false
|
loading = false
|
||||||
@ -166,7 +162,7 @@
|
|||||||
{#if loading}
|
{#if loading}
|
||||||
<!-- Loader -->
|
<!-- Loader -->
|
||||||
{:else if article}
|
{:else if article}
|
||||||
<Article entry="{article}" showDetails />
|
<ArticleDetails entry="{article}" />
|
||||||
{:else if content}
|
{:else if content}
|
||||||
<ArticlesList path="{path}" tags="{content?.tags}" />
|
<ArticlesList path="{path}" tags="{content?.tags}" />
|
||||||
{:else}
|
{:else}
|
||||||
|
29
src/components/widgets/details/Default.svelte
Normal file
29
src/components/widgets/details/Default.svelte
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let entry: TibiArticle
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if entry}
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="article-details {entry?.article?.general?.type}">
|
||||||
|
{#if entry?.article?.content?.title}
|
||||||
|
<h1 class="article-title">{@html entry?.article?.content?.title}</h1>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if entry?.article?.content?.subtitle}
|
||||||
|
<div class="article-subtitle">{@html entry?.article?.content?.subtitle}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if entry?.article?.content?.types?.teaser}
|
||||||
|
<div class="article-teaser">{@html entry?.article?.content?.types?.teaser}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if entry?.article?.content?.types?.details}
|
||||||
|
<div class="article-details">{@html entry?.article?.content?.types?.details}</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
29
src/components/widgets/details/News.svelte
Normal file
29
src/components/widgets/details/News.svelte
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
<script lang="ts">
|
||||||
|
export let entry: TibiArticle
|
||||||
|
</script>
|
||||||
|
|
||||||
|
{#if entry}
|
||||||
|
<div class="container">
|
||||||
|
<div class="row">
|
||||||
|
<div class="col-md-12">
|
||||||
|
<div class="article-details {entry?.article?.general?.type}">
|
||||||
|
{#if entry?.article?.content?.title}
|
||||||
|
<h1 class="article-title">{@html entry?.article?.content?.title}</h1>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if entry?.article?.content?.subtitle}
|
||||||
|
<div class="article-subtitle">{@html entry?.article?.content?.subtitle}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if entry?.article?.content?.types?.teaser}
|
||||||
|
<div class="article-teaser">{@html entry?.article?.content?.types?.teaser}</div>
|
||||||
|
{/if}
|
||||||
|
|
||||||
|
{#if entry?.article?.content?.types?.details}
|
||||||
|
<div class="article-details">{@html entry?.article?.content?.types?.details}</div>
|
||||||
|
{/if}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{/if}
|
7
src/components/widgets/details/index.ts
Normal file
7
src/components/widgets/details/index.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import Default from "./Default.svelte"
|
||||||
|
import News from "./News.svelte"
|
||||||
|
|
||||||
|
export default {
|
||||||
|
default: Default,
|
||||||
|
news: News,
|
||||||
|
}
|
@ -26,3 +26,14 @@ article,
|
|||||||
text-decoration: underline;
|
text-decoration: underline;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.article-details {
|
||||||
|
&.default {
|
||||||
|
background: #000;
|
||||||
|
color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.news {
|
||||||
|
background: #fc0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
1
types/global.d.ts
vendored
1
types/global.d.ts
vendored
@ -75,6 +75,7 @@ interface TibiArticle {
|
|||||||
article: {
|
article: {
|
||||||
general: {
|
general: {
|
||||||
public: boolean
|
public: boolean
|
||||||
|
type: string
|
||||||
locale: string
|
locale: string
|
||||||
publish_date: {
|
publish_date: {
|
||||||
from: string
|
from: string
|
||||||
|
Loading…
Reference in New Issue
Block a user