base zone components and type refinements

This commit is contained in:
Julian Krauser 2024-11-02 12:47:07 +01:00
parent 9d96e3a6dc
commit 5c56af0dad
38 changed files with 323 additions and 54 deletions

View file

@ -0,0 +1,13 @@
export default interface Article {
id: number;
documentId: string;
title: string;
description: string;
slug: string;
content: Array<{ type: string; children: Array<{ type: string; text: string }>; level?: number }>;
date: string;
createdAt: string;
updatedAt: string;
publishedAt: string;
locale: string;
}

View file

@ -1,3 +1,6 @@
import type { ComponentTypes } from "../component/baseComponent";
import type SharedHero from "../component/sharedHero";
export default interface Page {
id: number;
documentId: string;
@ -7,7 +10,7 @@ export default interface Page {
publishedAt: string;
locale: string;
slug: string;
Hero: { id: number; titel: string };
content: { __component: string; id: number; list: string; enable_detail: boolean }[];
hero: SharedHero;
content: Array<ComponentTypes>;
localizations: any[];
}

View file

@ -0,0 +1,30 @@
import type DynamicZoneColumnImageText from "./dynamicZoneColumnImageText";
import type DynamicZoneDualColumnText from "./dynamicZoneDualColumnText";
import type DynamicZoneEmphasiseArticle from "./dynamicZoneEmphasiseArticle";
import type DynamicZoneFullImage from "./dynamicZoneFullImage";
import type DynamicZoneFullText from "./dynamicZoneFullText";
import type DynamicZoneGallery from "./dynamicZoneGallery";
import type SharedList from "./sharedList";
export default interface BaseComponent {
__component: ComponentNames;
id: number;
}
export type ComponentNames =
| "shared.list"
| "dynamic-zone.gallery"
| "dynamic-zone.full-text"
| "dynamic-zone.full-image"
| "dynamic-zone.emphasise-article"
| "dynamic-zone.dual-column-text"
| "dynamic-zone.column-image-text";
export type ComponentTypes =
| SharedList
| DynamicZoneGallery
| DynamicZoneFullText
| DynamicZoneFullImage
| DynamicZoneEmphasiseArticle
| DynamicZoneDualColumnText
| DynamicZoneColumnImageText;

View file

@ -1,4 +1,4 @@
export default interface Image {
export default interface BaseImage {
id: number;
documentId: string;
name: string;
@ -6,7 +6,7 @@ export default interface Image {
caption: string | null;
width: number;
height: number;
formats: any;
formats: Record<string, ImageFormat> | null;
hash: string;
ext: string;
mime: string;
@ -19,3 +19,16 @@ export default interface Image {
updatedAt: string;
publishedAt: string;
}
export interface ImageFormat {
name: string;
hash: string;
ext: string;
mime: string;
path: string | null;
width: number;
height: number;
size: number;
sizeInBytes: number;
url: string;
}

View file

@ -0,0 +1,9 @@
import type BaseComponent from "./baseComponent";
import type BaseImage from "./baseImage";
export default interface DynamicZoneColumnImageText extends BaseComponent {
__component: "dynamic-zone.column-image-text";
text: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
image_left: boolean;
image: BaseImage;
}

View file

@ -0,0 +1,7 @@
import type BaseComponent from "./baseComponent";
export default interface DynamicZoneDualColumnText extends BaseComponent {
__component: "dynamic-zone.dual-column-text";
left_side: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
right_side: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
}

View file

@ -0,0 +1,9 @@
import type Article from "../collection/article";
import type BaseComponent from "./baseComponent";
export default interface DynamicZoneEmphasiseArticle extends BaseComponent {
__component: "dynamic-zone.emphasise-article";
titel: string;
description: string;
articles: Array<Article>;
}

View file

@ -0,0 +1,7 @@
import type BaseComponent from "./baseComponent";
import type BaseImage from "./baseImage";
export default interface DynamicZoneFullImage extends BaseComponent {
__component: "dynamic-zone.full-image";
image: BaseImage;
}

View file

@ -0,0 +1,6 @@
import type BaseComponent from "./baseComponent";
export default interface DynamicZoneFullText extends BaseComponent {
__component: "dynamic-zone.full-text";
text: Array<{ type: string; children: Array<{ type: string; text: string }> }>;
}

View file

@ -0,0 +1,7 @@
import type BaseComponent from "./baseComponent";
import type BaseImage from "./baseImage";
export default interface DynamicZoneGallery extends BaseComponent {
__component: "dynamic-zone.gallery";
images: Array<BaseImage>;
}

View file

@ -1,4 +1,4 @@
import type FooterLink from "./footerLink";
import type FooterLink from "./itemsFooterLink";
export default interface Footer {
id: number;

View file

@ -0,0 +1,8 @@
import type BaseImage from "./baseImage";
import type NavbarItem from "./itemsNavbarItem";
export default interface Navbar {
id: number;
logo: BaseImage;
navbar_items: NavbarItem[];
}

View file

@ -1,4 +1,4 @@
import type NavbarSubItem from "./navbarSubItem";
import type NavbarSubItem from "./itemsNavbarSubItem";
export default interface NavbarItem {
id: number;

View file

@ -1,8 +0,0 @@
import type Image from "./image";
import type NavbarItem from "./navbarItem";
export default interface Navbar {
id: number;
logo: Image;
navbar_items: NavbarItem[];
}

View file

@ -0,0 +1,7 @@
import type BaseImage from "./baseImage";
export default interface SharedHero {
id: number;
title: string;
banner: BaseImage;
}

View file

@ -0,0 +1,5 @@
export default interface SharedLink {
text: string;
URL: string;
target: "_blank" | "_self" | "_parent" | "_top";
}

View file

@ -0,0 +1,7 @@
import type BaseComponent from "./baseComponent";
export default interface SharedList extends BaseComponent {
__component: "shared.list";
list: string;
enable_detail: boolean;
}

View file

@ -1,5 +1,5 @@
import type Footer from "../component/footer";
import type Navbar from "../component/navbar";
import type Footer from "../component/globalFooter";
import type Navbar from "../component/globalNavbar";
export default interface Global {
id: number;

View file

@ -1,4 +1,5 @@
import type Image from "../component/image";
import type BaseImage from "../component/baseImage";
import type { ComponentTypes } from "../component/baseComponent";
export default interface Homepage {
id: number;
@ -7,6 +8,6 @@ export default interface Homepage {
updatedAt: string;
publishedAt: string;
locale: string;
backdrop: Image;
content: Array<any>;
backdrop: BaseImage;
content: Array<ComponentTypes>;
}