content text and dynamic zone components
This commit is contained in:
parent
44b55d9bbb
commit
3df3ba4ebc
22 changed files with 202 additions and 24 deletions
|
@ -42,3 +42,7 @@ a[primary-sublink].active {
|
||||||
[darkgray] {
|
[darkgray] {
|
||||||
@apply bg-darkgray text-white;
|
@apply bg-darkgray text-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
@apply text-xl;
|
||||||
|
}
|
||||||
|
|
|
@ -1,17 +1,56 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="min-h-[calc(100vh-9rem)] container mx-auto py-12">
|
<div class="min-h-[calc(100vh-9rem)] h-fit container mx-auto py-12">
|
||||||
{{ data }}
|
<h1>{{ data?.title }}</h1>
|
||||||
|
<p>
|
||||||
|
{{
|
||||||
|
new Date(data?.date ?? "").toLocaleString("de-DE", {
|
||||||
|
day: "2-digit",
|
||||||
|
month: "long",
|
||||||
|
year: "numeric",
|
||||||
|
minute: "2-digit",
|
||||||
|
hour: "2-digit",
|
||||||
|
})
|
||||||
|
}}
|
||||||
|
</p>
|
||||||
|
<br />
|
||||||
|
<p>{{ data?.description }}</p>
|
||||||
|
<br />
|
||||||
|
<NuxtPicture
|
||||||
|
v-if="data?.image"
|
||||||
|
loading="lazy"
|
||||||
|
class="w-fit h-[50vh] max-w-full object-cover object-center"
|
||||||
|
:src="baseUrl + data.image.url"
|
||||||
|
:imgAttrs="{ class: 'w-fit h-[50vh] max-w-full object-cover object-center' }"
|
||||||
|
/>
|
||||||
|
<br v-if="data?.image" />
|
||||||
|
<div v-if="data?.content">
|
||||||
|
<p>Bericht:</p>
|
||||||
|
<FieldContent :data="data.content" />
|
||||||
|
</div>
|
||||||
|
<br />
|
||||||
|
<div v-if="data?.attachment">
|
||||||
|
<p>Anhang:</p>
|
||||||
|
<div class="flex flex-row flex-wrap gap-2 w-full min-h-fit">
|
||||||
|
<NuxtPicture
|
||||||
|
v-for="img in data.attachment"
|
||||||
|
loading="lazy"
|
||||||
|
class="w-fit h-48 object-cover object-center"
|
||||||
|
:src="baseUrl + img.url"
|
||||||
|
:imgAttrs="{ class: 'w-fit h-48 object-cover object-center' }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import type SharedHero from "../types/component/sharedHero";
|
|
||||||
import type { ComponentTypes } from "../types/component/baseComponent";
|
|
||||||
import type Article from "../types/collection/article";
|
import type Article from "../types/collection/article";
|
||||||
import type Operation from "../types/collection/operation";
|
import type Operation from "../types/collection/operation";
|
||||||
import type Event from "../types/collection/event";
|
import type Event from "../types/collection/event";
|
||||||
|
|
||||||
|
const baseUrl = useStrapiUrl().replace("/api", "");
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
data: Object as PropType<Article | Operation | Event>,
|
data: Object as PropType<Article | Operation | Event>,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="min-h-[calc(100vh-9rem)] w-full">
|
<div class="min-h-[calc(100vh-9rem)] w-full">
|
||||||
<SharedHero v-if="hero" :data="hero" />
|
<SharedHero v-if="hero" :data="hero" />
|
||||||
<div class="container mx-auto py-12 min-h-[50vh]">
|
<div class="container mx-auto py-12 min-h-[50vh] flex flex-col gap-2">
|
||||||
<div v-for="item in content" class="contents">
|
<div v-for="item in content" class="contents">
|
||||||
<DynamicZoneColumnImageText v-if="item.__component == 'dynamic-zone.column-image-text'" :data="item" />
|
<DynamicZoneColumnImageText v-if="item.__component == 'dynamic-zone.column-image-text'" :data="item" />
|
||||||
<DynamicZoneDualColumnText v-else-if="item.__component == 'dynamic-zone.dual-column-text'" :data="item" />
|
<DynamicZoneDualColumnText v-else-if="item.__component == 'dynamic-zone.dual-column-text'" :data="item" />
|
||||||
|
@ -10,6 +10,7 @@
|
||||||
<DynamicZoneFullText v-else-if="item.__component == 'dynamic-zone.full-text'" :data="item" />
|
<DynamicZoneFullText v-else-if="item.__component == 'dynamic-zone.full-text'" :data="item" />
|
||||||
<DynamicZoneGallery v-else-if="item.__component == 'dynamic-zone.gallery'" :data="item" />
|
<DynamicZoneGallery v-else-if="item.__component == 'dynamic-zone.gallery'" :data="item" />
|
||||||
<SharedList v-else-if="item.__component == 'shared.list'" :data="item" />
|
<SharedList v-else-if="item.__component == 'shared.list'" :data="item" />
|
||||||
|
<br />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -1,11 +1,22 @@
|
||||||
<template>
|
<template>
|
||||||
<p>{{ data }}</p>
|
<div class="flex flex-row gap-4">
|
||||||
|
<NuxtPicture
|
||||||
|
loading="lazy"
|
||||||
|
class="w-1/2 min-w-[50%] h-fit object-cover object-center"
|
||||||
|
:class="data?.image_left ? 'order-0' : 'order-1'"
|
||||||
|
:src="baseUrl + data?.image.url"
|
||||||
|
:imgAttrs="{ class: 'w-full h-fit object-cover object-center' }"
|
||||||
|
/>
|
||||||
|
<FieldContent :data="data?.text" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import type DynamicZoneColumnImageText from "../../types/component/dynamicZoneColumnImageText";
|
import type DynamicZoneColumnImageText from "../../types/component/dynamicZoneColumnImageText";
|
||||||
|
|
||||||
|
const baseUrl = useStrapiUrl().replace("/api", "");
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
data: Object as PropType<DynamicZoneColumnImageText>,
|
data: Object as PropType<DynamicZoneColumnImageText>,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<p>{{ data }}</p>
|
<div class="flex flex-row gap-4">
|
||||||
|
<FieldContent :data="data?.left_side" />
|
||||||
|
<FieldContent :data="data?.right_side" />
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
@ -1,11 +1,18 @@
|
||||||
<template>
|
<template>
|
||||||
<p>{{ data }}</p>
|
<NuxtPicture
|
||||||
|
loading="lazy"
|
||||||
|
class="w-1/2 min-w-[50%] h-fit object-cover object-center mx-auto"
|
||||||
|
:src="baseUrl + data?.image.url"
|
||||||
|
:imgAttrs="{ class: 'w-full h-fit object-cover object-center' }"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import type DynamicZoneFullImage from "../../types/component/dynamicZoneFullImage";
|
import type DynamicZoneFullImage from "../../types/component/dynamicZoneFullImage";
|
||||||
|
|
||||||
|
const baseUrl = useStrapiUrl().replace("/api", "");
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
data: Object as PropType<DynamicZoneFullImage>,
|
data: Object as PropType<DynamicZoneFullImage>,
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<p>{{ data }}</p>
|
<FieldContent :data="data?.text" />
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
|
@ -1,11 +1,21 @@
|
||||||
<template>
|
<template>
|
||||||
<p>{{ data }}</p>
|
<div class="flex flex-row flex-wrap gap-2 w-full min-h-fit">
|
||||||
|
<NuxtPicture
|
||||||
|
v-for="img in data?.images"
|
||||||
|
loading="lazy"
|
||||||
|
class="w-fit h-48 object-cover object-center"
|
||||||
|
:src="baseUrl + img.url"
|
||||||
|
:imgAttrs="{ class: 'w-fit h-48 object-cover object-center' }"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import type { PropType } from "vue";
|
import type { PropType } from "vue";
|
||||||
import type DynamicZoneGallery from "../../types/component/dynamicZoneGallery";
|
import type DynamicZoneGallery from "../../types/component/dynamicZoneGallery";
|
||||||
|
|
||||||
|
const baseUrl = useStrapiUrl().replace("/api", "");
|
||||||
|
|
||||||
defineProps({
|
defineProps({
|
||||||
data: Object as PropType<DynamicZoneGallery>,
|
data: Object as PropType<DynamicZoneGallery>,
|
||||||
});
|
});
|
||||||
|
|
35
components/field/Content.vue
Normal file
35
components/field/Content.vue
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
<template>
|
||||||
|
<div class="w-full h-fit flex flex-col gap-2">
|
||||||
|
<div v-for="item in data" :key="item.type" class="contents">
|
||||||
|
<h1 v-if="item.type == 'heading'" class="w-full">
|
||||||
|
<FieldType v-for="child in item.children" :data="child" />
|
||||||
|
</h1>
|
||||||
|
<p v-else-if="item.type == 'paragraph'" class="w-full">
|
||||||
|
<FieldType v-for="child in item.children" :data="child" />
|
||||||
|
</p>
|
||||||
|
<div v-else-if="item.type == 'quote'" class="w-full p-3">
|
||||||
|
<p class="p-3 bg-gray-200 border-l-2 border-gray-500">
|
||||||
|
<FieldType v-for="child in item.children" :data="child" />
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<ol
|
||||||
|
v-else-if="item.type == 'list'"
|
||||||
|
class="w-full"
|
||||||
|
:class="item.format == 'unordered' ? 'list-disc' : 'list-decimal'"
|
||||||
|
>
|
||||||
|
<li v-for="list in item.children" class="ml-6">
|
||||||
|
<FieldType v-for="child in list.children" :data="child" />
|
||||||
|
</li>
|
||||||
|
</ol>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { PropType } from "vue";
|
||||||
|
import type ContentField from "../../types/field/content";
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
data: Object as PropType<ContentField>,
|
||||||
|
});
|
||||||
|
</script>
|
21
components/field/Text.vue
Normal file
21
components/field/Text.vue
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
<template>
|
||||||
|
<span
|
||||||
|
v-for="text in data"
|
||||||
|
:key="text.text"
|
||||||
|
:class="[
|
||||||
|
text.bold ? 'font-bold' : '',
|
||||||
|
text.strikethrough ? 'line-through' : '',
|
||||||
|
text.underline ? 'underline' : '',
|
||||||
|
text.italic ? 'italic' : '',
|
||||||
|
]"
|
||||||
|
>{{ text.text }}</span
|
||||||
|
>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { TextField } from "../../types/field/content";
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
data: Array<TextField>,
|
||||||
|
});
|
||||||
|
</script>
|
15
components/field/Type.vue
Normal file
15
components/field/Type.vue
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
<template>
|
||||||
|
<FieldText v-if="data?.type == 'text'" :data="[data]" />
|
||||||
|
<NuxtLink v-else :href="data?.url" class="text-primary">
|
||||||
|
<FieldText :data="data?.children" />
|
||||||
|
</NuxtLink>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import type { PropType } from "vue";
|
||||||
|
import type { TypeField } from "../../types/field/content";
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
data: Object as PropType<TypeField>,
|
||||||
|
});
|
||||||
|
</script>
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="flex flex-col w-full max-h-72 h-72 overflow-hidden">
|
<div class="flex flex-col w-full max-h-72 h-72 overflow-hidden">
|
||||||
<NuxtPicture
|
<NuxtPicture
|
||||||
preload
|
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class="w-full h-60 object-cover object-center"
|
class="w-full h-60 object-cover object-center"
|
||||||
:src="baseUrl + data?.banner.url"
|
:src="baseUrl + data?.banner.url"
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="relative h-[calc(100vh-6rem)] max-h-[calc(100vh-6rem)] w-full overflow-hidden">
|
<div class="relative h-[calc(100vh-6rem)] max-h-[calc(100vh-6rem)] w-full overflow-hidden">
|
||||||
<NuxtPicture
|
<NuxtPicture
|
||||||
preload
|
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
class="w-full h-full object-cover object-center"
|
class="w-full h-full object-cover object-center"
|
||||||
:src="baseUrl + backdrop.url"
|
:src="baseUrl + backdrop.url"
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
|
import type BaseImage from "../component/baseImage";
|
||||||
import type BaseCollection from "./baseCollection";
|
import type BaseCollection from "./baseCollection";
|
||||||
|
|
||||||
export default interface Article extends BaseCollection {
|
export default interface Article extends BaseCollection {}
|
||||||
content: Array<{ type: string; children: Array<{ type: string; text: string }>; level?: number }>;
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
import type BaseImage from "../component/baseImage";
|
||||||
|
import type ContentField from "../field/content";
|
||||||
|
|
||||||
export default interface BaseCollection {
|
export default interface BaseCollection {
|
||||||
id: number;
|
id: number;
|
||||||
documentId: string;
|
documentId: string;
|
||||||
|
@ -9,4 +12,8 @@ export default interface BaseCollection {
|
||||||
updatedAt: string;
|
updatedAt: string;
|
||||||
publishedAt: string;
|
publishedAt: string;
|
||||||
locale: string;
|
locale: string;
|
||||||
|
|
||||||
|
content: ContentField | undefined;
|
||||||
|
image: BaseImage | undefined;
|
||||||
|
attachment: Array<BaseImage>;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import type BaseCollection from "./baseCollection";
|
import type BaseCollection from "./baseCollection";
|
||||||
|
|
||||||
export default interface Event extends BaseCollection {
|
export default interface Event extends BaseCollection {
|
||||||
content: Array<{ type: string; children: Array<{ type: string; text: string }>; level?: number }>;
|
image: undefined;
|
||||||
|
content: undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ export default interface Lookup {
|
||||||
documentId: string;
|
documentId: string;
|
||||||
collection: string;
|
collection: string;
|
||||||
reference: string;
|
reference: string;
|
||||||
createdAt: Date;
|
createdAt: string;
|
||||||
updatedAt: Date;
|
updatedAt: string;
|
||||||
publishedAt: Date;
|
publishedAt: string;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import type BaseCollection from "./baseCollection";
|
import type BaseCollection from "./baseCollection";
|
||||||
|
|
||||||
export default interface Operation extends BaseCollection {
|
export default interface Operation extends BaseCollection {
|
||||||
content: Array<{ type: string; children: Array<{ type: string; text: string }>; level?: number }>;
|
image: undefined;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,9 +1,10 @@
|
||||||
|
import type ContentField from "../field/content";
|
||||||
import type BaseComponent from "./baseComponent";
|
import type BaseComponent from "./baseComponent";
|
||||||
import type BaseImage from "./baseImage";
|
import type BaseImage from "./baseImage";
|
||||||
|
|
||||||
export default interface DynamicZoneColumnImageText extends BaseComponent {
|
export default interface DynamicZoneColumnImageText extends BaseComponent {
|
||||||
__component: "dynamic-zone.column-image-text";
|
__component: "dynamic-zone.column-image-text";
|
||||||
text: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
|
text: ContentField;
|
||||||
image_left: boolean;
|
image_left: boolean;
|
||||||
image: BaseImage;
|
image: BaseImage;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
|
import type ContentField from "../field/content";
|
||||||
import type BaseComponent from "./baseComponent";
|
import type BaseComponent from "./baseComponent";
|
||||||
|
|
||||||
export default interface DynamicZoneDualColumnText extends BaseComponent {
|
export default interface DynamicZoneDualColumnText extends BaseComponent {
|
||||||
__component: "dynamic-zone.dual-column-text";
|
__component: "dynamic-zone.dual-column-text";
|
||||||
left_side: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
|
left_side: ContentField;
|
||||||
right_side: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
|
right_side: ContentField;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
|
import type ContentField from "../field/content";
|
||||||
import type BaseComponent from "./baseComponent";
|
import type BaseComponent from "./baseComponent";
|
||||||
|
|
||||||
export default interface DynamicZoneFullText extends BaseComponent {
|
export default interface DynamicZoneFullText extends BaseComponent {
|
||||||
__component: "dynamic-zone.full-text";
|
__component: "dynamic-zone.full-text";
|
||||||
text: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
|
text: ContentField;
|
||||||
}
|
}
|
||||||
|
|
24
types/field/content.ts
Normal file
24
types/field/content.ts
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
export default interface ContentField
|
||||||
|
extends Array<
|
||||||
|
| {
|
||||||
|
type: "paragraph" | "heading" | "quote";
|
||||||
|
children: Array<TypeField>;
|
||||||
|
level?: number;
|
||||||
|
}
|
||||||
|
| {
|
||||||
|
type: "list";
|
||||||
|
format: "unordered" | "ordered";
|
||||||
|
children: Array<{ type: "list-item"; children: Array<TypeField> }>;
|
||||||
|
}
|
||||||
|
> {}
|
||||||
|
|
||||||
|
export type TypeField = TextField | { type: "link"; url: string; children: Array<TextField> };
|
||||||
|
|
||||||
|
export type TextField = {
|
||||||
|
type: "text";
|
||||||
|
text: string;
|
||||||
|
strikethrough?: boolean;
|
||||||
|
underline?: boolean;
|
||||||
|
italic?: boolean;
|
||||||
|
bold?: boolean;
|
||||||
|
};
|
Loading…
Reference in a new issue