diff --git a/api/collections/articles.yml b/api/collections/articles.yml index 87b6fb7..0686d26 100644 --- a/api/collections/articles.yml +++ b/api/collections/articles.yml @@ -19,26 +19,22 @@ meta: mediaQuery: "(max-width:599px)" primaryText: path columns: - - source: article.general.locale - type: flag - article.general.public - article.content.title - - article.general.position - article.general.sort + - source: article.general.locale + type: flag # Desktop - type: table mediaQuery: "(min-width:600px)" columns: - - source: article.general.locale - type: flag - article.general.public - label: { de: "Titel", en: "Title" } source: article.content.title filter: true - - label: { de: "Position", en: "Position" } - source: article.general.position - filter: true - article.general.sort + - source: article.general.locale + type: flag imageFilter: xs: diff --git a/api/collections/fields/_article.yml b/api/collections/fields/_article.yml index 29d8fd8..f0e36ed 100644 --- a/api/collections/fields/_article.yml +++ b/api/collections/fields/_article.yml @@ -5,7 +5,7 @@ meta: label: de: Einstellungen zum Artikel en: Article Setings - activeTab: 0 + activeTab: 1 subFields: - name: general type: object @@ -61,6 +61,7 @@ subFields: label: de: Schlagworte / Tags / Labels en: Linking Tags + addAllowed: true defaultValue: [] choices: endpoint: "tags" @@ -106,7 +107,7 @@ subFields: label: de: Inhalt dieses Artikel en: Article Content - activeTab: 1 + activeTab: 2 subFields: - name: teaser type: string @@ -118,15 +119,14 @@ subFields: meta: widget: richtext label: { de: "Detail-Text des Artikel", en: "Article Detail Text" } - - name: contentMedia + - name: media type: object meta: label: de: Medien en: Media - css: subFields: - - name: mediaFiles + - name: files type: object[] meta: label: { de: "Bilder", en: "Images" } @@ -142,6 +142,7 @@ subFields: - name: id type: string meta: + editableWhileCreating: true label: { de: "Technischer Name / ID", en: "Technical name / ID" } - name: file type: file @@ -152,7 +153,7 @@ subFields: type: string meta: label: { de: "Bildunterschrift", en: "Caption" } - - name: contentAttachments + - name: attachments type: object meta: label: @@ -160,7 +161,7 @@ subFields: en: Attachments / Downloads css: subFields: - - name: attachments + - name: files type: object[] meta: label: { de: "Anhänge", en: "Attachments" } @@ -189,7 +190,7 @@ subFields: label: de: Erscheinungsbild en: Appearance - defaultValue: ["_self"] + defaultValue: top-left choices: - { id: "top", @@ -215,13 +216,8 @@ subFields: en: "Article picture under teaser (full width)", }, } - - { id: "top-left", name: { de: "Artikelbild oben links", en: "Article picture above left" } } + - { id: "default", name: { de: "Artikelbild oben links", en: "Article picture above left" } } - { id: "top-right", name: { de: "Artikelbild oben rechts", en: "Article picture above right" } } - - { id: "bottom-left", name: { de: "Artikelbild unten links", en: "Article picture below left" } } - - { - id: "bottom-right", - name: { de: "Artikelbild unten rechts", en: "Article picture below right" }, - } - name: properties type: object meta: diff --git a/src/api.ts b/src/api.ts index 3eecaf5..dc8e668 100644 --- a/src/api.ts +++ b/src/api.ts @@ -217,17 +217,25 @@ export const getGeneralInformation = async (): Promise => { } } -export const getArticles = async (): Promise => { +export const getArticles = async ( + collectionName: string, + filter: APIParams, + params?: APIParams +): Promise => { try { - let response = await api("articles", { + let response = await api(collectionName, { method: "get", offset: 0, + params, filter: { - active: true, + "article.general.public": true, + ...filter, }, + sort: "article.general.sort", }) return response.data } catch (e) { + console.error(e) return null } } diff --git a/src/components/routes/Home.svelte b/src/components/routes/Home.svelte index 3cea647..4c5b173 100644 --- a/src/components/routes/Home.svelte +++ b/src/components/routes/Home.svelte @@ -1,45 +1,36 @@ + let articleEntries: CollectionEntry[] = [] - + $: if ($currentLang) { + getArticles("articles", { + "article.general.locale": $currentLang, + }).then((response) => { + articleEntries = response + }) + } +
+
+
+ {#each articleEntries || [] as entry} +
+ {/each} +
+
diff --git a/src/components/widgets/Article.svelte b/src/components/widgets/Article.svelte index ab31c88..7206628 100644 --- a/src/components/widgets/Article.svelte +++ b/src/components/widgets/Article.svelte @@ -1,73 +1,77 @@ -
- {#if article?.position !== "content"} -
- {#if article?.title} -
{@html article?.title}
+{#if article} +
+ {#if article?.layout?.variant === "default"} + {#if article?.content?.types?.media?.files?.length} + {/if} - {#if article?.position === "top" || article?.position === "end-of-content"} - {#if article?.subtitle} -
- {@html article?.subtitle} -
- {/if} - {/if} -
- {/if} - - {#if article?.position !== "top"} -
- {#if article?.position === "content"} - {#if article?.title} -
{@html article?.title}
- {/if} - {/if} - {#if article?.position === "content" || article?.position === "top-of-content"} - {#if article?.subtitle} -
- {@html article?.subtitle} -
- {/if} + {#if article?.content?.title} +
{@html article?.content?.title}
{/if} - {#if !showDetails && article?.content} -
- {@html article?.content} + {#if article?.content?.subtitle} +
{@html article?.content?.subtitle}
+ {/if} + + {#if article?.content?.types?.teaser} + + {/if} + + {#if article?.content?.types?.details && showDetails} +
{@html article?.content?.types?.details}
+ {/if} + {:else if article?.layout?.variant === "left"} +
+
+ {#if article?.content?.types?.media?.files?.length} + + {/if}
- {/if} +
+ {#if article?.content?.title} +
{@html article?.content?.title}
+ {/if} - {#if showDetails && article?.details?.length} -
- {@html article?.details} + {#if article?.content?.subtitle} +
{@html article?.content?.subtitle}
+ {/if} + + {#if article?.content?.types?.teaser} + + {/if} + + {#if article?.content?.types?.details && showDetails} +
{@html article?.content?.types?.details}
+ {/if}
- {/if} -
- {/if} - - {#if !showDetails && article?.details} -
- Details -
- {/if} -
+
+ {/if} + +{/if} diff --git a/src/components/widgets/ContactInformation.svelte b/src/components/widgets/ContactInformation.svelte deleted file mode 100644 index 6cfe000..0000000 --- a/src/components/widgets/ContactInformation.svelte +++ /dev/null @@ -1,11 +0,0 @@ - - -
-
-
-
...
-
-
-
diff --git a/src/components/widgets/Image.svelte b/src/components/widgets/Image.svelte index 38ff936..0e8817d 100644 --- a/src/components/widgets/Image.svelte +++ b/src/components/widgets/Image.svelte @@ -9,7 +9,7 @@ {#if collectionName && entryId && file} - {#if file.src.includes(";base64,")} + {#if file?.src?.includes(";base64,")} {alt ? alt + ' - ' : ''}{file.path} {:else} {/if} {/if} + + diff --git a/src/components/widgets/TibiArticleMediaFile.svelte b/src/components/widgets/TibiArticleMediaFile.svelte new file mode 100644 index 0000000..0988546 --- /dev/null +++ b/src/components/widgets/TibiArticleMediaFile.svelte @@ -0,0 +1,12 @@ + + + diff --git a/src/css/theme-2022/components/article.less b/src/css/theme-2022/components/article.less index 86355b9..06d9c7b 100644 --- a/src/css/theme-2022/components/article.less +++ b/src/css/theme-2022/components/article.less @@ -1,211 +1,23 @@ article, .article { - font-size: 20px; - border-radius: 10px; overflow-wrap: anywhere; + background: rgba(0, 0, 0, 0.03); + padding: @space-md; - strong { + & ~ article, + & ~ .article { + margin-top: @space-md; + } + + .article-title { + color: @primary; + font-size: 2rem; + line-height: 2.4rem; + } + + .article-subtitle { color: @secondary; - font-weight: 600; - } - - &.top, - &.top-of-content, - &.end-of-content { - box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2); - border-radius: 10px; - background-color: @surface; - color: @on-surface; - display: flex; - flex-direction: column; - - .article-image { - min-height: 200px; - background-size: cover; - background-position: top center; - border-top-left-radius: 10px; - border-top-right-radius: 10px; - display: flex; - flex-direction: column; - justify-content: flex-end; - padding: 10px 20px; - color: #f1ebe4; - text-shadow: 0 2px 10px #000; - overflow-wrap: anywhere; - flex-grow: 1; - } - - .article-title { - font-size: 32px; - font-weight: 600; - overflow-wrap: anywhere; - } - - .article-subtitle { - font-size: 20px; - overflow-wrap: anywhere; - } - - .article-content { - padding: 20px; - overflow-wrap: anywhere; - - .article-subtitle { - font-size: @font-size-default; - } - } - - &.end-of-content { - .article-image { - height: 400px; - } - } - - .article-link { - background: @primary; - color: @on-primary; - border-bottom-left-radius: 10px; - border-bottom-right-radius: 10px; - height: 44px; - font-size: 20px; - font-weight: 700; - display: flex; - justify-content: center; - align-items: center; - cursor: pointer; - } - } - - ul { - list-style-type: none; - padding-left: 0px; - - li { - background-image: url("../css/theme/components/img/arrow-right-3.png"); - background-repeat: no-repeat; - - line-height: 30px; - padding-left: 35px; - color: @primary; - font-weight: 700; - font-size: 20px; - } - } - - .article-content { - strong { - color: @primary; - font-weight: 600; - } - - .article-title:not(h1) { - color: @primary; - font-size: 32px; - font-weight: 700; - margin-bottom: @space-sm; - } - - .article-subtitle { - color: @secondary; - font-size: 20px; - font-weight: 700; - margin-bottom: @space-md; - } - } - - &.content { - margin-bottom: @space-lg; - - .article-link { - border: 1px solid @primary; - border-bottom: 3px solid #c4253e; - color: @primary; - font-size: 18px; - font-weight: 700; - padding: 5px 10px; - border-radius: 10px; - transition: @transition-default; - display: inline-flex; - justify-content: center; - align-items: center; - gap: @space-sm; - text-decoration: none; - cursor: pointer; - - &:hover { - background: @on-primary; - color: @primary; - box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2); - } - } - } - - &.end-of-content { - .article-image { - justify-content: flex-start; - - .article-title { - margin-top: 20px; - color: #fff; - font-family: "Caveat", sans-serif; - text-shadow: none; - font-size: 72px; - line-height: 72px; - font-weight: 700; - padding-right: 10%; - } - .article-subtitle { - color: #fff; - font-family: "Caveat", sans-serif; - text-shadow: none; - font-size: 32px; - font-weight: 700; - } - } - } - - &.article-details { - img { - border-radius: 10px; - width: 300px; - display: inline-block; - - &.layout-1 { - float: left; - margin: 0 @space-md @space-md 0; - } - &.layout-2 { - float: right; - margin: 0 0 @space-md @space-md; - } - } - - .article-subtitle { - font-size: 24px; - } - - .article-link { - margin-top: @space-lg; - border: 1px solid @primary; - border-bottom: 3px solid #c4253e; - color: @primary; - font-size: 18px; - font-weight: 700; - padding: 5px 10px; - border-radius: 10px; - transition: @transition-default; - display: inline-flex; - justify-content: center; - align-items: center; - gap: @space-sm; - text-decoration: none; - cursor: pointer; - - &:hover { - background: @on-primary; - color: @primary; - box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2); - } - } + font-size: 1.4rem; + line-height: 1.8rem; } } diff --git a/src/css/theme-2022/main.less b/src/css/theme-2022/main.less index 356abca..37bd88d 100644 --- a/src/css/theme-2022/main.less +++ b/src/css/theme-2022/main.less @@ -51,5 +51,6 @@ @import "components/top-section"; @import "components/forms"; @import "components/language-chooser"; +@import "components/article"; @import "components/cc-bar"; diff --git a/src/store.ts b/src/store.ts index faf2d7b..bc258c5 100644 --- a/src/store.ts +++ b/src/store.ts @@ -34,15 +34,6 @@ const getGeneralProjectInformation = async () => { } getGeneralProjectInformation() -// Articles - -// export const articles = writable() -// const getAllArticles = async () => { -// const list = await getArticles() -// articles.set(list) -// } -// getAllArticles() - // Navigations export const navigations = writable([]) diff --git a/types/global.d.ts b/types/global.d.ts index 777f6c9..9ac119a 100644 --- a/types/global.d.ts +++ b/types/global.d.ts @@ -7,6 +7,14 @@ interface APIParams { } count?: 1 } + +interface CollectionEntry { + id?: string + insertTime?: string + updateTime?: string + [key: string]: any +} + interface ContentBlock { layout: 1 | 2 | 3 | 4 title?: string @@ -64,15 +72,17 @@ interface GeneralInfo { interface TibiArticle { id: string - active: boolean - content: string - details: string - image: File - insertTime: string - position: string - subtitle: string + article: any + insertTime?: string + updateTime?: string +} + +interface TibiArticleImage { + id: string title: string - updateTime: string + alternateText: string + caption: string + file: File[] } interface File {