base zone components and type refinements
This commit is contained in:
parent
9d96e3a6dc
commit
5c56af0dad
38 changed files with 323 additions and 54 deletions
13
types/collection/article.ts
Normal file
13
types/collection/article.ts
Normal 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;
|
||||
}
|
|
@ -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[];
|
||||
}
|
||||
|
|
30
types/component/baseComponent.ts
Normal file
30
types/component/baseComponent.ts
Normal 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;
|
|
@ -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;
|
||||
}
|
9
types/component/dynamicZoneColumnImageText.ts
Normal file
9
types/component/dynamicZoneColumnImageText.ts
Normal 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;
|
||||
}
|
7
types/component/dynamicZoneDualColumnText.ts
Normal file
7
types/component/dynamicZoneDualColumnText.ts
Normal 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 }> }>;
|
||||
}
|
9
types/component/dynamicZoneEmphasiseArticle.ts
Normal file
9
types/component/dynamicZoneEmphasiseArticle.ts
Normal 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>;
|
||||
}
|
7
types/component/dynamicZoneFullImage.ts
Normal file
7
types/component/dynamicZoneFullImage.ts
Normal 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;
|
||||
}
|
6
types/component/dynamicZoneFullText.ts
Normal file
6
types/component/dynamicZoneFullText.ts
Normal 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 }> }>;
|
||||
}
|
7
types/component/dynamicZoneGallery.ts
Normal file
7
types/component/dynamicZoneGallery.ts
Normal 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>;
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import type FooterLink from "./footerLink";
|
||||
import type FooterLink from "./itemsFooterLink";
|
||||
|
||||
export default interface Footer {
|
||||
id: number;
|
8
types/component/globalNavbar.ts
Normal file
8
types/component/globalNavbar.ts
Normal 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[];
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import type NavbarSubItem from "./navbarSubItem";
|
||||
import type NavbarSubItem from "./itemsNavbarSubItem";
|
||||
|
||||
export default interface NavbarItem {
|
||||
id: number;
|
|
@ -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[];
|
||||
}
|
7
types/component/sharedHero.ts
Normal file
7
types/component/sharedHero.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import type BaseImage from "./baseImage";
|
||||
|
||||
export default interface SharedHero {
|
||||
id: number;
|
||||
title: string;
|
||||
banner: BaseImage;
|
||||
}
|
5
types/component/sharedLink.ts
Normal file
5
types/component/sharedLink.ts
Normal file
|
@ -0,0 +1,5 @@
|
|||
export default interface SharedLink {
|
||||
text: string;
|
||||
URL: string;
|
||||
target: "_blank" | "_self" | "_parent" | "_top";
|
||||
}
|
7
types/component/sharedList.ts
Normal file
7
types/component/sharedList.ts
Normal file
|
@ -0,0 +1,7 @@
|
|||
import type BaseComponent from "./baseComponent";
|
||||
|
||||
export default interface SharedList extends BaseComponent {
|
||||
__component: "shared.list";
|
||||
list: string;
|
||||
enable_detail: boolean;
|
||||
}
|
|
@ -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;
|
||||
|
|
|
@ -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>;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue