feat: json rich text editor, blocks, asides, general structure

This commit is contained in:
Simon Emanuelsson
2024-02-07 11:57:36 +01:00
parent 2bd4e25403
commit 66faa41e98
53 changed files with 966 additions and 211 deletions

View File

@@ -1,17 +0,0 @@
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
>
}
}
}

View File

@@ -1,14 +1,12 @@
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"
import type { Embeds } from "../embeds"
import type { RTEDocument } from "@/types/rte/node"
export type Text = {
text: {
content: {
json: RTERootObject
embedded_itemsConnection: Edges<ExternalLink | PageLink | SysAsset>
embedded_itemsConnection: Edges<Embeds>
json: RTEDocument
}
}
}

View File

@@ -5,10 +5,12 @@ 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 { Preamble } from "./preamble"
import type { Text } from "./blocks/text"
import type { AllRequestResponse } from "./utils/all"
import type { AsideTypenameEnum, Typename } from "./utils/typename"
import type { EmbedEnum } from "./utils/embeds"
import type { Edges } from "./utils/edges"
export type Asides =
| Typename<Contact, AsideTypenameEnum.CurrentBlocksPageAsideContact>
@@ -16,14 +18,38 @@ export type Asides =
export type Blocks =
| Typename<List, BlocksTypenameEnum.CurrentBlocksPageBlocksList>
| Typename<Preamble, BlocksTypenameEnum.CurrentBlocksPageBlocksPreamble>
| Typename<PuffBlock, BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs>
| Typename<Text, BlocksTypenameEnum.CurrentBlocksPageBlocksText>
interface SharedBreadcrumb {
breadcrumbs: {
title?: string
} | null
title: string
url: string
}
export interface CurrentBlocksPageBreadcrumb extends SharedBreadcrumb {
__typename: EmbedEnum.CurrentBlocksPage
}
export interface TempPageBreadcrumb extends SharedBreadcrumb {
__typename: EmbedEnum.TempPage
}
export type Breadcrumb = CurrentBlocksPageBreadcrumb | TempPageBreadcrumb
export type Breadcrumbs = {
parentsConnection: Edges<Breadcrumb>
title: string
}
export type BlockPage = {
aside: Asides[]
blocks: Blocks[]
breadcrumbs: Breadcrumbs
hero: Hero
preamble: Preamble
title: string
url: string
}

8
types/requests/embeds.ts Normal file
View File

@@ -0,0 +1,8 @@
import type { SysAsset } from "./utils/asset"
import type { ExternalLinkType } from "./utils/externalLink"
import type { PageLinkType } from "./utils/pageLink"
export type Embeds =
| ExternalLinkType
| PageLinkType
| SysAsset

View File

@@ -1,16 +1,11 @@
import type { AllRequestResponse } from "./utils/all"
import type { Edges } from "./utils/edges"
import { Asset } from "./utils/asset"
import { PageLink } from "./utils/pageLink"
type AppDownloadLink = {
title: string
url: string
}
import type { Image } from "../image"
import type { PageLink } from "./utils/pageLink"
type AppDownload = {
href: string
imageConnection: Edges<Asset>
imageConnection: Edges<Image>
}
export type InternalLink = {
@@ -52,7 +47,7 @@ export type Footer = {
app_store: AppDownload
google_play: AppDownload
}
logoConnection: Edges<Asset>
logoConnection: Edges<Image>
navigation: NavigationItem[]
social_media: {
title: string
@@ -62,7 +57,7 @@ export type Footer = {
}
trip_advisor: {
title: string
logoConnection: Edges<Asset>
logoConnection: Edges<Image>
}
}

View File

@@ -0,0 +1,10 @@
import type { Edges } from "./utils/edges"
import type { RTEDocument } from "../rte/node"
import type { Embeds } from "./embeds"
export type Preamble = {
text: {
embedded_itemsConnection: Edges<Embeds>
json: RTEDocument
}
}

View File

@@ -1,13 +1,12 @@
import type { Image } from "../image"
import type { Edges } from "./utils/edges"
import type { Embeds } from "./embeds"
import type { ExternalLink } from "./utils/externalLink"
import type { PageLink } from "./utils/pageLink"
import type { Typename } from "./utils/typename"
import type { RTEDocument } from "../rte/node"
export type Puff = {
imageConnection: Edges<{
title: string
url: string
}>
imageConnection: Edges<Image>
is_internal: boolean
link: {
href: string
@@ -15,12 +14,12 @@ export type Puff = {
}
link_text?: string
pageConnection: Edges<ExternalLink | PageLink>
system: {
uid: string
}
text: {
json: JSON
embedded_itemsConnection: Edges<Typename<{
title: string
url: string
}, "SysAsset">>
embedded_itemsConnection: Edges<Embeds>
json: RTEDocument
}
title: string
}

View File

@@ -1,8 +1,5 @@
import type { EmbedEnum } from "./embeds"
import type { Image } from "@/types/image"
import type { Typename } from "./typename"
export type Asset = {
title: string
url: string
}
export type SysAsset = Typename<Asset, "SysAsset">
export type SysAsset = Typename<Image, EmbedEnum.SysAsset>

View File

@@ -0,0 +1,7 @@
export enum EmbedEnum {
CurrentBlocksPage = "CurrentBlocksPage",
SysAsset = "SysAsset",
TempPage = "TempPage",
}
export type Embed = keyof typeof EmbedEnum

View File

@@ -1,5 +1,12 @@
import type { EmbedEnum } from "./embeds"
import type { Typename } from "./typename"
export type ExternalLink = {
__typename: "TempPage"
system: {
uid: string
}
title: string
url: string
}
export type ExternalLinkType = Typename<ExternalLink, EmbedEnum.TempPage>

View File

@@ -1,5 +1,12 @@
import type { EmbedEnum } from "./embeds"
import type { Typename } from "./typename"
export type PageLink = {
__typename: "CurrentBlocksPage"
system: {
uid: string
}
title: string
url: string
}
}
export type PageLinkType = Typename<PageLink, EmbedEnum.CurrentBlocksPage>

View File

@@ -1,8 +1,3 @@
export const AsideTypenames = {
CurrentBlocksPageAsideContact: "CurrentBlocksPageAsideContact",
CurrentBlocksPageAsidePuff: "CurrentBlocksPageAsidePuff",
}
export enum AsideTypenameEnum {
CurrentBlocksPageAsideContact = "CurrentBlocksPageAsideContact",
CurrentBlocksPageAsidePuff = "CurrentBlocksPageAsidePuff",
@@ -10,15 +5,6 @@ export enum AsideTypenameEnum {
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",
@@ -26,6 +12,8 @@ export enum BlocksTypenameEnum {
CurrentBlocksPageBlocksText = "CurrentBlocksPageBlocksText",
}
export type BlocksTypename = keyof typeof BlocksTypenameEnum
export type Typename<T, K> = T & {
__typename: K
}