feat: graphql client with fetches for initial pages
This commit is contained in:
5
types/components/current/aside.ts
Normal file
5
types/components/current/aside.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { Asides } from "@/types/requests/currentBlockPage"
|
||||
|
||||
export type AsideProps = {
|
||||
blocks: Asides[]
|
||||
}
|
||||
5
types/components/current/blocks.ts
Normal file
5
types/components/current/blocks.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
import type { Blocks } from "@/types/requests/currentBlockPage"
|
||||
|
||||
export type BlocksProps = {
|
||||
blocks: Blocks[]
|
||||
}
|
||||
3
types/components/current/blocks/text.ts
Normal file
3
types/components/current/blocks/text.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
import type { Text } from "@/types/requests/blocks/text"
|
||||
|
||||
export type TextProps = Text
|
||||
7
types/components/current/hero.ts
Normal file
7
types/components/current/hero.ts
Normal file
@@ -0,0 +1,7 @@
|
||||
import type { Image } from "@/types/image"
|
||||
|
||||
export type HeroProps = {
|
||||
images: {
|
||||
node: Image
|
||||
}[]
|
||||
}
|
||||
1
types/graphql.d.ts
vendored
Normal file
1
types/graphql.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
declare module '*.graphql'
|
||||
8
types/image.ts
Normal file
8
types/image.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export type Image = {
|
||||
dimension: {
|
||||
height: number
|
||||
width: number
|
||||
}
|
||||
title: string
|
||||
url: string
|
||||
}
|
||||
3
types/request.ts
Normal file
3
types/request.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
export type Data<T> = {
|
||||
data: T
|
||||
}
|
||||
23
types/requests/asides/contact.ts
Normal file
23
types/requests/asides/contact.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
import type { Edges } from "../utils/edges"
|
||||
|
||||
export type Contact = {
|
||||
contact: {
|
||||
contactConnection: Edges<{
|
||||
mailing_address: {
|
||||
city: string
|
||||
country: string
|
||||
name: string
|
||||
street: string
|
||||
zip: string
|
||||
}
|
||||
phone: string
|
||||
title: string
|
||||
visiting_address: {
|
||||
city: string
|
||||
country: string
|
||||
street: string
|
||||
zip: string
|
||||
}
|
||||
}>
|
||||
}
|
||||
}
|
||||
8
types/requests/asides/puff.ts
Normal file
8
types/requests/asides/puff.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Puff } from "../puff"
|
||||
import type { Edges } from "../utils/edges"
|
||||
|
||||
export type PuffAside = {
|
||||
puff: {
|
||||
puffConnection: Edges<Puff>
|
||||
}
|
||||
}
|
||||
46
types/requests/blocks/list.ts
Normal file
46
types/requests/blocks/list.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { Edges } from "../utils/edges"
|
||||
import type { ExternalLink } from "../utils/externalLink"
|
||||
import type { PageLink } from "../utils/pagelink"
|
||||
|
||||
enum ListItemStyleEnum {
|
||||
checkmark = "checkmark",
|
||||
default = "default",
|
||||
}
|
||||
|
||||
type ListItemStyle = keyof typeof ListItemStyleEnum
|
||||
|
||||
type ExternalLinkListItem = {
|
||||
list_item_external_link: {
|
||||
link: {
|
||||
href: string
|
||||
title: string
|
||||
}
|
||||
list_item_style: ListItemStyle
|
||||
subtitle?: string
|
||||
}
|
||||
}
|
||||
|
||||
type InternalLinkListItem = {
|
||||
list_item_internal_link: {
|
||||
link_text?: string
|
||||
list_item_style: ListItemStyle
|
||||
subtitle?: string
|
||||
pageConnection: Edges<ExternalLink | PageLink>
|
||||
}
|
||||
}
|
||||
|
||||
type RegularListItem = {
|
||||
list_item: {
|
||||
list_item_style: ListItemStyle
|
||||
subtitle?: string
|
||||
title: string
|
||||
}
|
||||
}
|
||||
|
||||
type ListItem = ExternalLinkListItem | InternalLinkListItem | RegularListItem
|
||||
|
||||
export type List = {
|
||||
list: {
|
||||
list_items: ListItem
|
||||
}
|
||||
}
|
||||
17
types/requests/blocks/preamble.ts
Normal file
17
types/requests/blocks/preamble.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import type { SysAsset } from "../utils/asset"
|
||||
import type { Edges } from "../utils/edges"
|
||||
import type { ExternalLink } from "../utils/externalLink"
|
||||
import type { PageLink } from "../utils/pagelink"
|
||||
|
||||
export type Preamble = {
|
||||
preamble: {
|
||||
text: {
|
||||
json: JSON
|
||||
embedded_itemsConnection: Edges<
|
||||
| ExternalLink
|
||||
| PageLink
|
||||
| SysAsset
|
||||
>
|
||||
}
|
||||
}
|
||||
}
|
||||
8
types/requests/blocks/puff.ts
Normal file
8
types/requests/blocks/puff.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Edges } from "../utils/edges"
|
||||
import type { Puff } from "../puff"
|
||||
|
||||
export type PuffBlock = {
|
||||
puffs: {
|
||||
puffsConnection: Edges<Puff>
|
||||
}
|
||||
}
|
||||
19
types/requests/blocks/text.ts
Normal file
19
types/requests/blocks/text.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import type { RTERootObject } from "@/types/rte"
|
||||
import type { SysAsset } from "../utils/asset"
|
||||
import type { Edges } from "../utils/edges"
|
||||
import type { ExternalLink } from "../utils/externalLink"
|
||||
import type { PageLink } from "../utils/pagelink"
|
||||
|
||||
export type Text = {
|
||||
text: {
|
||||
content: {
|
||||
json: RTERootObject
|
||||
embedded_itemsConnection: Edges<
|
||||
| ExternalLink
|
||||
| PageLink
|
||||
| SysAsset
|
||||
>
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
33
types/requests/currentBlockPage.ts
Normal file
33
types/requests/currentBlockPage.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { BlocksTypenameEnum } from "./utils/typename"
|
||||
|
||||
import type { Contact } from "./asides/contact"
|
||||
import type { PuffAside } from "./asides/puff"
|
||||
import type { Hero } from "./hero"
|
||||
import type { List } from "./blocks/list"
|
||||
import type { PuffBlock } from "./blocks/puff"
|
||||
import type { Preamble } from "./blocks/preamble"
|
||||
import type { Text } from "./blocks/text"
|
||||
import type { AllRequestResponse } from "./utils/all"
|
||||
import type { AsideTypenameEnum, Typename } from "./utils/typename"
|
||||
|
||||
export type Asides =
|
||||
| Typename<Contact, AsideTypenameEnum.CurrentBlocksPageAsideContact>
|
||||
| Typename<PuffAside, AsideTypenameEnum.CurrentBlocksPageAsidePuff>
|
||||
|
||||
export type Blocks =
|
||||
| Typename<List, BlocksTypenameEnum.CurrentBlocksPageBlocksList>
|
||||
| Typename<Preamble, BlocksTypenameEnum.CurrentBlocksPageBlocksPreamble>
|
||||
| Typename<PuffBlock, BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs>
|
||||
| Typename<Text, BlocksTypenameEnum.CurrentBlocksPageBlocksText>
|
||||
|
||||
export type BlockPage = {
|
||||
aside: Asides[]
|
||||
blocks: Blocks[]
|
||||
hero: Hero
|
||||
title: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export type GetCurrentBlockPageData = {
|
||||
all_current_blocks_page: AllRequestResponse<BlockPage>
|
||||
}
|
||||
6
types/requests/hero.ts
Normal file
6
types/requests/hero.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
import type { Image } from "../image"
|
||||
import type { Edges } from "./utils/edges"
|
||||
|
||||
export type Hero = {
|
||||
imagesConnection: Edges<Image>
|
||||
}
|
||||
26
types/requests/puff.ts
Normal file
26
types/requests/puff.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import type { Edges } from "./utils/edges"
|
||||
import type { ExternalLink } from "./utils/externalLink"
|
||||
import type { PageLink } from "./utils/pagelink"
|
||||
import type { Typename } from "./utils/typename"
|
||||
|
||||
export type Puff = {
|
||||
imageConnection: Edges<{
|
||||
title: string
|
||||
url: string
|
||||
}>
|
||||
is_internal: boolean
|
||||
link: {
|
||||
href: string
|
||||
title: string
|
||||
}
|
||||
link_text?: string
|
||||
pageConnection: Edges<ExternalLink | PageLink>
|
||||
text: {
|
||||
json: JSON
|
||||
embedded_itemsConnection: Edges<Typename<{
|
||||
title: string
|
||||
url: string
|
||||
}, "SysAsset">>
|
||||
}
|
||||
title: string
|
||||
}
|
||||
4
types/requests/utils/all.ts
Normal file
4
types/requests/utils/all.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export type AllRequestResponse<T> = {
|
||||
items: T[]
|
||||
total: number
|
||||
}
|
||||
8
types/requests/utils/asset.ts
Normal file
8
types/requests/utils/asset.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
import type { Typename } from "./typename"
|
||||
|
||||
export type Asset = {
|
||||
title: string
|
||||
url: string
|
||||
}
|
||||
|
||||
export type SysAsset = Typename<Asset, "SysAsset">
|
||||
8
types/requests/utils/edges.ts
Normal file
8
types/requests/utils/edges.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
export type Node<T> = {
|
||||
node: T
|
||||
}
|
||||
|
||||
export type Edges<T> = {
|
||||
edges: Node<T>[]
|
||||
totalCount: number
|
||||
}
|
||||
5
types/requests/utils/externalLink.ts
Normal file
5
types/requests/utils/externalLink.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export type ExternalLink = {
|
||||
__typename: "TempPage"
|
||||
title: string
|
||||
url: string
|
||||
}
|
||||
5
types/requests/utils/pageLink.ts
Normal file
5
types/requests/utils/pageLink.ts
Normal file
@@ -0,0 +1,5 @@
|
||||
export type PageLink = {
|
||||
__typename: "CurrentBlocksPage"
|
||||
title: string
|
||||
url: string
|
||||
}
|
||||
31
types/requests/utils/typename.ts
Normal file
31
types/requests/utils/typename.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
export const AsideTypenames = {
|
||||
CurrentBlocksPageAsideContact: "CurrentBlocksPageAsideContact",
|
||||
CurrentBlocksPageAsidePuff: "CurrentBlocksPageAsidePuff",
|
||||
}
|
||||
|
||||
export enum AsideTypenameEnum {
|
||||
CurrentBlocksPageAsideContact = "CurrentBlocksPageAsideContact",
|
||||
CurrentBlocksPageAsidePuff = "CurrentBlocksPageAsidePuff",
|
||||
}
|
||||
|
||||
export type AsideTypename = keyof typeof AsideTypenameEnum
|
||||
|
||||
export const blocksTypenameEnum = {
|
||||
CurrentBlocksPageBlocksList: "CurrentBlocksPageBlocksList",
|
||||
CurrentBlocksPageBlocksPreamble: "CurrentBlocksPageBlocksPreamble",
|
||||
CurrentBlocksPageBlocksPuffs: "CurrentBlocksPageBlocksPuffs",
|
||||
CurrentBlocksPageBlocksText: "CurrentBlocksPageBlocksText",
|
||||
}
|
||||
|
||||
export type BlocksTypename = keyof typeof blocksTypenameEnum
|
||||
|
||||
export enum BlocksTypenameEnum {
|
||||
CurrentBlocksPageBlocksList = "CurrentBlocksPageBlocksList",
|
||||
CurrentBlocksPageBlocksPreamble = "CurrentBlocksPageBlocksPreamble",
|
||||
CurrentBlocksPageBlocksPuffs = "CurrentBlocksPageBlocksPuffs",
|
||||
CurrentBlocksPageBlocksText = "CurrentBlocksPageBlocksText",
|
||||
}
|
||||
|
||||
export type Typename<T, K> = T & {
|
||||
__typename: K
|
||||
}
|
||||
58
types/rte.ts
Normal file
58
types/rte.ts
Normal file
@@ -0,0 +1,58 @@
|
||||
export const rteType = {
|
||||
asset: "asset",
|
||||
p: "p",
|
||||
reference: "reference",
|
||||
}
|
||||
|
||||
export enum RTETypeEnum {
|
||||
asset = "asset",
|
||||
p = "p",
|
||||
reference = "reference",
|
||||
}
|
||||
|
||||
export type RTEType = keyof typeof rteType
|
||||
|
||||
export type RTEText = {
|
||||
text: string
|
||||
}
|
||||
|
||||
export type RTEAssetAttrs = {
|
||||
"alt": string
|
||||
"asset-alt": string
|
||||
"asset-link": string
|
||||
"asset-name": string
|
||||
"asset-type": "image/png" | "image/jpg" | "image/jpeg"
|
||||
"asset-uid": string
|
||||
"display-type": "display"
|
||||
"class-name": string
|
||||
"content-type-uid": "sys_assets"
|
||||
"inline": false
|
||||
"type": RTETypeEnum.asset
|
||||
}
|
||||
|
||||
type RTEBaseObject<T> = {
|
||||
type: T
|
||||
uid: string
|
||||
}
|
||||
|
||||
type AssetReferenceObject = RTEBaseObject<RTETypeEnum.reference> & {
|
||||
attrs: RTEAssetAttrs
|
||||
children: RTEText[]
|
||||
}
|
||||
|
||||
export type RTEObject =
|
||||
| AssetReferenceObject
|
||||
| {
|
||||
attrs: Record<string, any>
|
||||
children: (RTEObject | RTEText)[]
|
||||
type: RTEType
|
||||
uid: string
|
||||
}
|
||||
|
||||
export type RTERootObject = {
|
||||
attrs: RTEAssetAttrs | Record<string, any>
|
||||
children: RTEObject[]
|
||||
uid: string
|
||||
type: "doc"
|
||||
_version: number
|
||||
}
|
||||
Reference in New Issue
Block a user