Merged in feat/intial-blocks (pull request #16)
feat: json rich text editor, blocks, asides, general structure Approved-by: Michael Zetterberg
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import { notFound } from "next/navigation";
|
import { notFound } from "next/navigation"
|
||||||
|
|
||||||
import { request } from "@/lib/request"
|
import { request } from "@/lib/request"
|
||||||
import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql"
|
import { GetCurrentBlockPage } from "@/lib/graphql/Query/CurrentBlockPage.graphql"
|
||||||
@@ -7,6 +7,9 @@ import Aside from "@/components/Current/Aside"
|
|||||||
import Blocks from "@/components/Current/Blocks"
|
import Blocks from "@/components/Current/Blocks"
|
||||||
import Header from "@/components/Current/Header"
|
import Header from "@/components/Current/Header"
|
||||||
import Hero from "@/components/Current/Hero"
|
import Hero from "@/components/Current/Hero"
|
||||||
|
import Preamble from "@/components/Current/Preamble"
|
||||||
|
import Section from "@/components/Current/Section"
|
||||||
|
import SubnavMobile from "@/components/Current/SubnavMobile"
|
||||||
|
|
||||||
import type { PageArgs, LangParams, UriParams } from "@/types/params"
|
import type { PageArgs, LangParams, UriParams } from "@/types/params"
|
||||||
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
import type { GetCurrentBlockPageData } from "@/types/requests/currentBlockPage"
|
||||||
@@ -34,14 +37,31 @@ export default async function CurrentContentPage({
|
|||||||
|
|
||||||
const page = response.data.all_current_blocks_page.items[0]
|
const page = response.data.all_current_blocks_page.items[0]
|
||||||
const images = page.hero?.imagesConnection
|
const images = page.hero?.imagesConnection
|
||||||
|
const breadcrumbs = page.breadcrumbs.parentsConnection
|
||||||
|
const parent = breadcrumbs.edges.at(-1)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Header lang={params.lang} pathname={searchParams.uri} />
|
<Header lang={params.lang} pathname={searchParams.uri} />
|
||||||
{images?.totalCount ? <Hero images={images.edges} /> : null}
|
{images?.totalCount ? <Hero images={images.edges} /> : null}
|
||||||
<main className="main l-sections-wrapper" id="maincontent" role="main">
|
<main
|
||||||
<Blocks blocks={page.blocks} />
|
className="main l-sections-wrapper"
|
||||||
<Aside blocks={page.aside} />
|
id="maincontent"
|
||||||
|
role="main"
|
||||||
|
>
|
||||||
|
<input id="lbl-personalized-areas" name="lbl-personalized-areas" type="hidden" value="" />
|
||||||
|
<SubnavMobile breadcrumbs={breadcrumbs} parent={parent} title={page.breadcrumbs.title} />
|
||||||
|
<Preamble
|
||||||
|
breadcrumbs={breadcrumbs}
|
||||||
|
breadcrumbParent={parent}
|
||||||
|
breadcrumbTitle={page.breadcrumbs.title}
|
||||||
|
preamble={page.preamble}
|
||||||
|
title={page.title}
|
||||||
|
/>
|
||||||
|
<Section>
|
||||||
|
<Blocks blocks={page.blocks} />
|
||||||
|
<Aside blocks={page.aside} />
|
||||||
|
</Section>
|
||||||
</main>
|
</main>
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,9 +1,34 @@
|
|||||||
|
import { Fragment } from "react"
|
||||||
|
|
||||||
|
import Puff from "./Asides/Puff"
|
||||||
|
|
||||||
|
import { AsideTypenameEnum } from "@/types/requests/utils/typename"
|
||||||
import type { AsideProps } from "@/types/components/current/aside"
|
import type { AsideProps } from "@/types/components/current/aside"
|
||||||
|
|
||||||
export default function Aside({ }: AsideProps) {
|
export default function Aside({ blocks }: AsideProps) {
|
||||||
return (
|
if (!blocks?.length) {
|
||||||
<>
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
</>
|
return (
|
||||||
|
<aside>
|
||||||
|
{blocks.map((block, idx) => {
|
||||||
|
const type = block.__typename
|
||||||
|
switch (type) {
|
||||||
|
case AsideTypenameEnum.CurrentBlocksPageAsideContact:
|
||||||
|
return null
|
||||||
|
case AsideTypenameEnum.CurrentBlocksPageAsidePuff:
|
||||||
|
return (
|
||||||
|
<Fragment key={`puff-${idx}`}>
|
||||||
|
{block.puff.puffConnection.edges.map(puff => (
|
||||||
|
<Puff key={puff.node.system.uid} {...puff.node} />
|
||||||
|
))}
|
||||||
|
</Fragment>
|
||||||
|
)
|
||||||
|
default:
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})}
|
||||||
|
</aside>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
60
components/Current/Asides/Puff/index.tsx
Normal file
60
components/Current/Asides/Puff/index.tsx
Normal file
@@ -0,0 +1,60 @@
|
|||||||
|
import { renderOptions } from "./renderOptions"
|
||||||
|
|
||||||
|
import Image from "next/image"
|
||||||
|
import JsonToHtml from "@/components/JsonToHtml"
|
||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
|
import styles from "./puff.module.css"
|
||||||
|
|
||||||
|
import type { PuffProps } from "@/types/components/current/asides/puff"
|
||||||
|
|
||||||
|
export default function Puff({ imageConnection, is_internal, link, link_text, pageConnection, system, text, title }: PuffProps) {
|
||||||
|
return is_internal ? (
|
||||||
|
<Link className={styles.link} href={link.href}>
|
||||||
|
<PuffContent
|
||||||
|
imageConnection={imageConnection}
|
||||||
|
text={text}
|
||||||
|
title={title}
|
||||||
|
/>
|
||||||
|
</Link>
|
||||||
|
) : (
|
||||||
|
<a className={styles.link} href={link.href} target="_blank">
|
||||||
|
<PuffContent
|
||||||
|
imageConnection={imageConnection}
|
||||||
|
text={text}
|
||||||
|
title={title}
|
||||||
|
/>
|
||||||
|
</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function PuffContent({ imageConnection, text, title }: Pick<PuffProps, "imageConnection" | "text" | "title">) {
|
||||||
|
return (
|
||||||
|
<article>
|
||||||
|
{imageConnection.edges.map(image => (
|
||||||
|
<Image
|
||||||
|
alt={image.node.title}
|
||||||
|
className={styles.image}
|
||||||
|
height={image.node.dimension.height}
|
||||||
|
key={image.node.system.uid}
|
||||||
|
src={image.node.url}
|
||||||
|
unoptimized
|
||||||
|
width={image.node.dimension.width}
|
||||||
|
/>
|
||||||
|
))}
|
||||||
|
<section className={styles.content}>
|
||||||
|
<header className="content-teaser__body-wrapper">
|
||||||
|
<h3 className={styles.heading}>
|
||||||
|
{title}
|
||||||
|
</h3>
|
||||||
|
</header>
|
||||||
|
<JsonToHtml
|
||||||
|
embeds={text.embedded_itemsConnection.edges}
|
||||||
|
nodes={text.json.children}
|
||||||
|
renderOptions={renderOptions}
|
||||||
|
/>
|
||||||
|
</section>
|
||||||
|
</article>
|
||||||
|
)
|
||||||
|
}
|
||||||
47
components/Current/Asides/Puff/puff.module.css
Normal file
47
components/Current/Asides/Puff/puff.module.css
Normal file
@@ -0,0 +1,47 @@
|
|||||||
|
.link {
|
||||||
|
display: inline-block;
|
||||||
|
transition: 200ms ease;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link:hover {
|
||||||
|
text-decoration: none;
|
||||||
|
transform: scale(1.01);
|
||||||
|
}
|
||||||
|
|
||||||
|
.image {
|
||||||
|
height: auto;
|
||||||
|
object-fit: contain;
|
||||||
|
object-position: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content {
|
||||||
|
padding: 20px 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.heading {
|
||||||
|
color: #00838e;
|
||||||
|
font-family: Helvetica, Arial, sans-serif;
|
||||||
|
font-weight: 400;
|
||||||
|
line-height: normal;
|
||||||
|
margin-bottom: 0;
|
||||||
|
text-decoration: none;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link:hover .heading {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
|
||||||
|
.p {
|
||||||
|
color: #333;
|
||||||
|
line-height: 1.3;
|
||||||
|
margin-bottom: 0;
|
||||||
|
padding-top: 7px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 950px) {
|
||||||
|
.heading {
|
||||||
|
font-size: 1.375rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
components/Current/Asides/Puff/renderOptions.tsx
Normal file
13
components/Current/Asides/Puff/renderOptions.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import styles from "./puff.module.css"
|
||||||
|
|
||||||
|
import { RTETypeEnum } from "@/types/rte/enums"
|
||||||
|
|
||||||
|
import type { EmbedByUid } from "@/types/components/jsontohtml"
|
||||||
|
import type { RTENext, RTEDefaultNode } from "@/types/rte/node"
|
||||||
|
import type { RenderOptions } from "@/types/rte/option"
|
||||||
|
|
||||||
|
export const renderOptions: RenderOptions = {
|
||||||
|
[RTETypeEnum.p]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <p className={styles.p}>{next(node.children, embeds, fullRenderOptions)}</p>
|
||||||
|
},
|
||||||
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
import List from "./Blocks/List"
|
import List from "./Blocks/List"
|
||||||
import Preamble from "./Blocks/Preamble"
|
|
||||||
import Puffs from "./Blocks/Puffs"
|
import Puffs from "./Blocks/Puffs"
|
||||||
import Text from "./Blocks/Text"
|
import Text from "./Blocks/Text"
|
||||||
|
|
||||||
@@ -12,14 +11,12 @@ export default function Blocks({ blocks }: BlocksProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<section id="mainbody_personalized">
|
||||||
{blocks.map(block => {
|
{blocks.map(block => {
|
||||||
const type = block.__typename
|
const type = block.__typename
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksList:
|
||||||
return <List key={block.__typename} {...block} />
|
return <List key={block.__typename} {...block} />
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksPreamble:
|
|
||||||
return <Preamble key={block.__typename} {...block} />
|
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs:
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs:
|
||||||
return <Puffs key={block.__typename} {...block} />
|
return <Puffs key={block.__typename} {...block} />
|
||||||
case BlocksTypenameEnum.CurrentBlocksPageBlocksText:
|
case BlocksTypenameEnum.CurrentBlocksPageBlocksText:
|
||||||
@@ -29,6 +26,7 @@ export default function Blocks({ blocks }: BlocksProps) {
|
|||||||
return null
|
return null
|
||||||
}
|
}
|
||||||
})}
|
})}
|
||||||
</>
|
<div id="mainarea_personalized"></div>
|
||||||
|
</section>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +0,0 @@
|
|||||||
export default function Preamble() {
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
|
|
||||||
</>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -1,32 +1,12 @@
|
|||||||
import { rteType } from "@/types/rte";
|
import JsonToHtml from "@/components/JsonToHtml";
|
||||||
|
|
||||||
import Image from "next/image";
|
|
||||||
|
|
||||||
import type { TextProps } from "@/types/components/current/blocks/text"
|
import type { TextProps } from "@/types/components/current/blocks/text"
|
||||||
|
|
||||||
export default function Text({ text }: TextProps) {
|
export default function Text({ text }: TextProps) {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<JsonToHtml
|
||||||
<pre>{JSON.stringify(text.content.json, null, 2)}</pre>
|
embeds={text.content.embedded_itemsConnection.edges}
|
||||||
{text.content.json.children.map(block => {
|
nodes={text.content.json.children}
|
||||||
switch (block.type) {
|
/>
|
||||||
case rteType.reference: {
|
|
||||||
if (block.attrs.type === rteType.asset) {
|
|
||||||
// return (
|
|
||||||
// <Image
|
|
||||||
// alt={block.attrs.alt}
|
|
||||||
// src={block.attrs["asset-link"]}
|
|
||||||
// />
|
|
||||||
// )
|
|
||||||
}
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
})}
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,12 +18,13 @@ export default async function Footer({ lang }: LangParams) {
|
|||||||
<div className="global-footer__content">
|
<div className="global-footer__content">
|
||||||
<h2 className="global-footer__content__heading">
|
<h2 className="global-footer__content__heading">
|
||||||
<Image
|
<Image
|
||||||
src={footerData.logoConnection.edges[0].node.url}
|
|
||||||
data-js="scandiclogoimg"
|
|
||||||
alt={footerData.logoConnection.edges[0].node.title}
|
alt={footerData.logoConnection.edges[0].node.title}
|
||||||
height="22"
|
data-js="scandiclogoimg"
|
||||||
width="102"
|
|
||||||
data-nosvgsrc="/Static/img/scandic-logotype-white.png" // what here?
|
data-nosvgsrc="/Static/img/scandic-logotype-white.png" // what here?
|
||||||
|
height="22"
|
||||||
|
src={footerData.logoConnection.edges[0].node.url}
|
||||||
|
unoptimized
|
||||||
|
width="102"
|
||||||
/>
|
/>
|
||||||
<span className="hidden--accessible">Scandic</span>
|
<span className="hidden--accessible">Scandic</span>
|
||||||
</h2>
|
</h2>
|
||||||
@@ -72,12 +73,13 @@ export default async function Footer({ lang }: LangParams) {
|
|||||||
rel="noopener"
|
rel="noopener"
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
height={45}
|
|
||||||
width={135}
|
|
||||||
src={footerData.app_downloads.app_store.imageConnection.edges[0].node.url}
|
|
||||||
alt={
|
alt={
|
||||||
footerData.app_downloads.app_store.imageConnection.edges[0].node.title
|
footerData.app_downloads.app_store.imageConnection.edges[0].node.title
|
||||||
}
|
}
|
||||||
|
height={45}
|
||||||
|
src={footerData.app_downloads.app_store.imageConnection.edges[0].node.url}
|
||||||
|
unoptimized
|
||||||
|
width={135}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -95,14 +97,15 @@ export default async function Footer({ lang }: LangParams) {
|
|||||||
rel="noopener"
|
rel="noopener"
|
||||||
>
|
>
|
||||||
<Image
|
<Image
|
||||||
height={45}
|
|
||||||
width={135}
|
|
||||||
src={
|
|
||||||
footerData.app_downloads.google_play.imageConnection.edges[0].node.url
|
|
||||||
}
|
|
||||||
alt={
|
alt={
|
||||||
footerData.app_downloads.google_play.imageConnection.edges[0].node.title
|
footerData.app_downloads.google_play.imageConnection.edges[0].node.title
|
||||||
}
|
}
|
||||||
|
height={45}
|
||||||
|
src={
|
||||||
|
footerData.app_downloads.google_play.imageConnection.edges[0].node.url
|
||||||
|
}
|
||||||
|
unoptimized
|
||||||
|
width={135}
|
||||||
/>
|
/>
|
||||||
</a>
|
</a>
|
||||||
</td>
|
</td>
|
||||||
@@ -215,10 +218,11 @@ display: none;
|
|||||||
<div className="global-footer__trip-advisor">
|
<div className="global-footer__trip-advisor">
|
||||||
<h3 className="heading-5 u-uppercase">{footerData.trip_advisor.title}</h3>
|
<h3 className="heading-5 u-uppercase">{footerData.trip_advisor.title}</h3>
|
||||||
<Image
|
<Image
|
||||||
width={160}
|
alt="Trip Advisor logotype"
|
||||||
height={24}
|
height={24}
|
||||||
src={footerData.trip_advisor.logoConnection.edges[0].node.url}
|
src={footerData.trip_advisor.logoConnection.edges[0].node.url}
|
||||||
alt="Trip Advisor logotype"
|
unoptimized
|
||||||
|
width={160}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
.nav {
|
||||||
|
padding-bottom: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.list {
|
||||||
|
align-items: center;
|
||||||
|
display: grid;
|
||||||
|
gap: 7px;
|
||||||
|
grid-auto-flow: column;
|
||||||
|
justify-content: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.link {
|
||||||
|
color: #333;
|
||||||
|
}
|
||||||
|
|
||||||
|
.currentPage {
|
||||||
|
color: #7f7369;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.currentPage,
|
||||||
|
.li {
|
||||||
|
font-size: .875rem;
|
||||||
|
line-height: 1.4em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.li::before,
|
||||||
|
.currentPage::before {
|
||||||
|
content: "›";
|
||||||
|
margin-right: 4px;
|
||||||
|
}
|
||||||
31
components/Current/Preamble/Breadcrumbs/index.tsx
Normal file
31
components/Current/Preamble/Breadcrumbs/index.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
|
import styles from "./breadcrumbs.module.css"
|
||||||
|
|
||||||
|
import type { BreadcrumbsProps } from "@/types/components/current/breadcrumbs"
|
||||||
|
|
||||||
|
export default function Breadcrumbs({ breadcrumbs, parent, title }: BreadcrumbsProps) {
|
||||||
|
return (
|
||||||
|
<nav className={styles.nav}>
|
||||||
|
<ul className={styles.list}>
|
||||||
|
{parent ? (
|
||||||
|
<li className="breadcrumb-list__parent hidden-medium hidden-large">
|
||||||
|
<Link href={parent.node.url}>
|
||||||
|
{parent.node.breadcrumbs?.title ?? parent.node.title}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
) : null}
|
||||||
|
{breadcrumbs.edges.map(breadcrumb => (
|
||||||
|
<li className={styles.li} itemProp="breadcrumb" key={breadcrumb.node.title}>
|
||||||
|
<Link className={styles.link} href={breadcrumb.node.url}>
|
||||||
|
{breadcrumb.node.breadcrumbs?.title ?? breadcrumb.node.title}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
<li className={styles.currentPage}>
|
||||||
|
<span>{title}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
)
|
||||||
|
}
|
||||||
26
components/Current/Preamble/index.tsx
Normal file
26
components/Current/Preamble/index.tsx
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
import { renderOptions } from "./renderOptions"
|
||||||
|
|
||||||
|
import Breadcrumbs from "./Breadcrumbs"
|
||||||
|
import JsonToHtml from "@/components/JsonToHtml"
|
||||||
|
|
||||||
|
import styles from "./preamble.module.css"
|
||||||
|
|
||||||
|
import type { PreambleProps } from "@/types/components/current/preamble"
|
||||||
|
|
||||||
|
export default function Preamble({ breadcrumbs, breadcrumbParent, breadcrumbTitle, preamble, title }: PreambleProps) {
|
||||||
|
return (
|
||||||
|
<section className={styles.container}>
|
||||||
|
<section>
|
||||||
|
<Breadcrumbs breadcrumbs={breadcrumbs} parent={breadcrumbParent} title={breadcrumbTitle} />
|
||||||
|
<h1>{title}</h1>
|
||||||
|
{preamble?.text ? (
|
||||||
|
<JsonToHtml
|
||||||
|
embeds={preamble.text.embedded_itemsConnection.edges}
|
||||||
|
nodes={preamble.text.json.children}
|
||||||
|
renderOptions={renderOptions}
|
||||||
|
/>
|
||||||
|
) : null}
|
||||||
|
</section>
|
||||||
|
</section>
|
||||||
|
)
|
||||||
|
}
|
||||||
25
components/Current/Preamble/preamble.module.css
Normal file
25
components/Current/Preamble/preamble.module.css
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
.container {
|
||||||
|
display: grid;
|
||||||
|
gap: 60px;
|
||||||
|
grid-template-columns: 2fr 1fr;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 1200px;
|
||||||
|
padding: 30px 0px 45px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.preamble {
|
||||||
|
color: #333;
|
||||||
|
font-family: Helvetica Neue, Roboto, Helvetica, Arial, sans-serif;
|
||||||
|
font-size: 1.25rem;
|
||||||
|
font-weight: 300;
|
||||||
|
line-height: normal;
|
||||||
|
margin-bottom: 0px;
|
||||||
|
text-transform: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 950px) {
|
||||||
|
.preamble {
|
||||||
|
font-size: 1.5rem;
|
||||||
|
line-height: 2.25rem;
|
||||||
|
}
|
||||||
|
}
|
||||||
13
components/Current/Preamble/renderOptions.tsx
Normal file
13
components/Current/Preamble/renderOptions.tsx
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import styles from "./preamble.module.css"
|
||||||
|
|
||||||
|
import { RTETypeEnum } from "@/types/rte/enums"
|
||||||
|
|
||||||
|
import type { EmbedByUid } from "@/types/components/jsontohtml"
|
||||||
|
import type { RTENext, RTEDefaultNode } from "@/types/rte/node"
|
||||||
|
import type { RenderOptions } from "@/types/rte/option"
|
||||||
|
|
||||||
|
export const renderOptions: RenderOptions = {
|
||||||
|
[RTETypeEnum.p]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <p className={styles.preamble}>{next(node.children, embeds, fullRenderOptions)}</p>
|
||||||
|
},
|
||||||
|
}
|
||||||
11
components/Current/Section/index.tsx
Normal file
11
components/Current/Section/index.tsx
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
import styles from "./section.module.css"
|
||||||
|
|
||||||
|
export default function Section({ children }: React.PropsWithChildren) {
|
||||||
|
return (
|
||||||
|
<div className={styles.wrapper}>
|
||||||
|
<section className={styles.section}>
|
||||||
|
{children}
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
25
components/Current/Section/section.module.css
Normal file
25
components/Current/Section/section.module.css
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
.wrapper {
|
||||||
|
background-color: #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.section {
|
||||||
|
box-sizing: content-box;
|
||||||
|
display: grid;
|
||||||
|
gap: 70px;
|
||||||
|
grid-template-columns: 2fr 1fr;
|
||||||
|
margin: 0 auto;
|
||||||
|
max-width: 1200px;
|
||||||
|
padding: 20px 10px 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 740px) {
|
||||||
|
.section {
|
||||||
|
padding: 30px 30px 15px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media screen and (min-width: 1200px) {
|
||||||
|
.section {
|
||||||
|
padding: 50px 30px 35px;
|
||||||
|
}
|
||||||
|
}
|
||||||
31
components/Current/SubnavMobile.tsx
Normal file
31
components/Current/SubnavMobile.tsx
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
|
import type { SubnavMobileProps } from "@/types/components/current/subnavMobile"
|
||||||
|
|
||||||
|
export default async function SubnavMobile({ breadcrumbs, parent, title }: SubnavMobileProps) {
|
||||||
|
return (
|
||||||
|
<div className="subnav-mobile hidden-small hidden-medium hidden-large">
|
||||||
|
<nav className="u-flex">
|
||||||
|
<ul className="breadcrumb-list hidden-small hidden-medium hidden-large">
|
||||||
|
{parent ? (
|
||||||
|
<li className="breadcrumb-list__parent hidden-medium hidden-large">
|
||||||
|
<Link href={parent.node.url}>
|
||||||
|
{parent.node.breadcrumbs?.title ?? parent.node.title}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
) : null}
|
||||||
|
{breadcrumbs.edges.map(breadcrumb => (
|
||||||
|
<li className="breadcrumb-list__body" key={breadcrumb.node.url}>
|
||||||
|
<Link href={breadcrumb.node.url}>
|
||||||
|
{breadcrumb.node.breadcrumbs?.title ?? breadcrumb.node.title}
|
||||||
|
</Link>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
<li className="breadcrumb-list__body">
|
||||||
|
<span>{title}</span>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
</nav>
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
10
components/JsonToHtml/index.tsx
Normal file
10
components/JsonToHtml/index.tsx
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import { nodesToHtml } from "./utils"
|
||||||
|
|
||||||
|
import type { JsonToHtmlProps } from "@/types/components/jsontohtml"
|
||||||
|
|
||||||
|
export default function JsonToHtml({ embeds, nodes, renderOptions = {} }: JsonToHtmlProps) {
|
||||||
|
if (!Array.isArray(nodes) || !nodes.length) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return <>{nodesToHtml(nodes, embeds, renderOptions).filter(Boolean)}</>
|
||||||
|
}
|
||||||
6
components/JsonToHtml/jsontohtml.module.css
Normal file
6
components/JsonToHtml/jsontohtml.module.css
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
.image {
|
||||||
|
height: auto;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
max-width: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
116
components/JsonToHtml/renderOptions.tsx
Normal file
116
components/JsonToHtml/renderOptions.tsx
Normal file
@@ -0,0 +1,116 @@
|
|||||||
|
import Image from "next/image"
|
||||||
|
import Link from "next/link"
|
||||||
|
|
||||||
|
import { EmbedEnum } from "@/types/requests/utils/embeds"
|
||||||
|
import { RTEItemTypeEnum, RTETypeEnum } from "@/types/rte/enums"
|
||||||
|
import { RTEMarkType } from "@/types/rte/node"
|
||||||
|
|
||||||
|
import styles from "./jsontohtml.module.css"
|
||||||
|
|
||||||
|
import type { EmbedByUid } from "@/types/components/jsontohtml"
|
||||||
|
import type { RTENext, RTEDefaultNode, RTENode, RTERegularNode } from "@/types/rte/node"
|
||||||
|
import type { RenderOptions } from "@/types/rte/option"
|
||||||
|
|
||||||
|
export const renderOptions: RenderOptions = {
|
||||||
|
[RTETypeEnum.a]: (node: RTERegularNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
if (node.attrs.url) {
|
||||||
|
return (
|
||||||
|
<a href={node.attrs.url} target={node.attrs.target ?? "_blank"}>{next(node.children, embeds, fullRenderOptions)}</a>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
[RTETypeEnum.h1]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <h1 className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</h1>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.h2]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <h2 className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</h2>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.h3]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <h3 className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</h3>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.h4]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <h4 className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</h4>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.h5]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <h5 className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</h5>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.h6]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <h6 className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</h6>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.p]: (node: RTEDefaultNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
return <p className={node.attrs["class-name"] ?? ""}>{next(node.children, embeds, fullRenderOptions)}</p>
|
||||||
|
},
|
||||||
|
[RTETypeEnum.reference]: (node: RTENode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => {
|
||||||
|
if ("attrs" in node) {
|
||||||
|
const type = node.attrs.type
|
||||||
|
if (type === RTEItemTypeEnum.asset) {
|
||||||
|
const image = embeds?.[node?.attrs?.["asset-uid"]]
|
||||||
|
if (image.node.__typename === EmbedEnum.SysAsset) {
|
||||||
|
const alt = image?.node?.title ?? node.attrs.alt
|
||||||
|
return (
|
||||||
|
<Image
|
||||||
|
alt={alt}
|
||||||
|
className={styles.image}
|
||||||
|
height={image.node.dimension.height}
|
||||||
|
src={image?.node?.url}
|
||||||
|
unoptimized
|
||||||
|
width={image.node.dimension.width}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return (
|
||||||
|
<Link href={node.attrs.href}>
|
||||||
|
{next(node.children, embeds, fullRenderOptions)}
|
||||||
|
</Link>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null
|
||||||
|
},
|
||||||
|
|
||||||
|
[RTEMarkType.bold]: (children: React.ReactNode) => {
|
||||||
|
return <strong>{children}</strong>
|
||||||
|
},
|
||||||
|
[RTEMarkType.italic]: (children: React.ReactNode) => {
|
||||||
|
return <em>{children}</em>
|
||||||
|
},
|
||||||
|
[RTEMarkType.underline]: (children: React.ReactNode) => {
|
||||||
|
return <u>{children}</u>
|
||||||
|
},
|
||||||
|
[RTEMarkType.strikethrough]: (children: React.ReactNode) => {
|
||||||
|
return <s>{children}</s>
|
||||||
|
},
|
||||||
|
[RTEMarkType.inlineCode]: (children: React.ReactNode) => {
|
||||||
|
return <span>{children}</span>
|
||||||
|
},
|
||||||
|
[RTEMarkType.subscript]: (children: React.ReactNode) => {
|
||||||
|
return <sub>{children}</sub>
|
||||||
|
},
|
||||||
|
[RTEMarkType.superscript]: (children: React.ReactNode) => {
|
||||||
|
return <sup>{children}</sup>
|
||||||
|
},
|
||||||
|
[RTEMarkType.break]: (children: React.ReactNode) => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<br />
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
},
|
||||||
|
[RTEMarkType.classnameOrId]: (children: React.ReactNode, className?: string, id?: string) => {
|
||||||
|
let props = {
|
||||||
|
className,
|
||||||
|
id,
|
||||||
|
}
|
||||||
|
if (!className) {
|
||||||
|
delete props.className
|
||||||
|
}
|
||||||
|
if (!id) {
|
||||||
|
delete props.id
|
||||||
|
}
|
||||||
|
return <span {...props}>{children}</span>
|
||||||
|
}
|
||||||
|
}
|
||||||
85
components/JsonToHtml/utils.tsx
Normal file
85
components/JsonToHtml/utils.tsx
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
import { renderOptions } from "./renderOptions"
|
||||||
|
|
||||||
|
import { RTEMarkType, RTERenderMark } from "@/types/rte/node"
|
||||||
|
import { RTETypeEnum } from "@/types/rte/enums"
|
||||||
|
|
||||||
|
import type { EmbedByUid } from "@/types/components/jsontohtml"
|
||||||
|
import type { Node } from "@/types/requests/utils/edges"
|
||||||
|
import type { RenderOptions } from "@/types/rte/option"
|
||||||
|
import type { RTENode, RTETextNode, RTERenderOptionComponent } from "@/types/rte/node"
|
||||||
|
import type { Embeds } from "@/types/requests/embeds"
|
||||||
|
|
||||||
|
export function groupEmbedsByUid(embedsArray: Node<Embeds>[]) {
|
||||||
|
const embedsByUid = embedsArray
|
||||||
|
.reduce<EmbedByUid>((acc, embed) => {
|
||||||
|
if (embed.node.system.uid) {
|
||||||
|
acc[embed.node.system.uid] = embed
|
||||||
|
}
|
||||||
|
return acc
|
||||||
|
}, {})
|
||||||
|
|
||||||
|
return embedsByUid
|
||||||
|
}
|
||||||
|
|
||||||
|
export function nodeChildrenToHtml(nodes: RTENode[], embeds: EmbedByUid, fullRenderOptions: RenderOptions): any {
|
||||||
|
return nodes.map(node => nodeToHtml(node, embeds, fullRenderOptions))
|
||||||
|
}
|
||||||
|
|
||||||
|
export function textNodeToHtml(node: RTETextNode, fullRenderOptions: RenderOptions) {
|
||||||
|
let text = <>{node.text}</>;
|
||||||
|
|
||||||
|
if (node.classname || node.id) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.classnameOrId] as RTERenderMark)(text, node.classname, node.id);
|
||||||
|
}
|
||||||
|
if (node.break) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.break] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.superscript) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.superscript] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.subscript) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.subscript] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.inlineCode) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.inlineCode] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.strikethrough) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.strikethrough] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.underline) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.underline] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.italic) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.italic] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
if (node.bold) {
|
||||||
|
text = (fullRenderOptions[RTEMarkType.bold] as RTERenderMark)(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
return text;
|
||||||
|
}
|
||||||
|
|
||||||
|
function next(nodes: RTENode[], embeds: EmbedByUid, fullRenderOptions: RenderOptions) {
|
||||||
|
return nodeChildrenToHtml(nodes, embeds, fullRenderOptions)
|
||||||
|
}
|
||||||
|
|
||||||
|
export function nodeToHtml(node: RTENode, embeds: EmbedByUid, fullRenderOptions: RenderOptions) {
|
||||||
|
if ("type" in node === false) {
|
||||||
|
return textNodeToHtml(node, fullRenderOptions);
|
||||||
|
} else {
|
||||||
|
if (fullRenderOptions[node.type] !== undefined) {
|
||||||
|
if (node.type === RTETypeEnum.doc) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return (fullRenderOptions[node.type] as RTERenderOptionComponent)(node, embeds, next, fullRenderOptions);
|
||||||
|
} else {
|
||||||
|
return next(node.children, embeds, fullRenderOptions);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function nodesToHtml(nodes: RTENode[], embedsArray: Node<Embeds>[], overrideRenderOptions: RenderOptions) {
|
||||||
|
const embeds = groupEmbedsByUid(embedsArray)
|
||||||
|
const fullRenderOptions = { ...renderOptions, ...overrideRenderOptions }
|
||||||
|
return nodes.map(node => nodeToHtml(node, embeds, fullRenderOptions))
|
||||||
|
}
|
||||||
@@ -28,6 +28,7 @@ fragment ListItemInternalLink on CurrentBlocksPageBlocksListBlockListItemsListIt
|
|||||||
totalCount
|
totalCount
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
__typename
|
||||||
...CurrentBlocksPageLink
|
...CurrentBlocksPageLink
|
||||||
...TempPageLink
|
...TempPageLink
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#import "../Image.graphql"
|
||||||
#import "../PageLinks.graphql"
|
#import "../PageLinks.graphql"
|
||||||
|
|
||||||
fragment TextBlock on CurrentBlocksPageBlocksText {
|
fragment TextBlock on CurrentBlocksPageBlocksText {
|
||||||
@@ -7,12 +8,10 @@ fragment TextBlock on CurrentBlocksPageBlocksText {
|
|||||||
totalCount
|
totalCount
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
__typename
|
||||||
...CurrentBlocksPageLink
|
...CurrentBlocksPageLink
|
||||||
|
...Image
|
||||||
...TempPageLink
|
...TempPageLink
|
||||||
... on SysAsset {
|
|
||||||
title
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
25
lib/graphql/Fragments/Breadcrumbs.graphql
Normal file
25
lib/graphql/Fragments/Breadcrumbs.graphql
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
fragment Breadcrumbs on CurrentBlocksPage {
|
||||||
|
breadcrumbs {
|
||||||
|
title
|
||||||
|
parentsConnection {
|
||||||
|
edges {
|
||||||
|
node {
|
||||||
|
... on CurrentBlocksPage {
|
||||||
|
breadcrumbs {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
title
|
||||||
|
url
|
||||||
|
}
|
||||||
|
... on TempPage {
|
||||||
|
breadcrumbs {
|
||||||
|
title
|
||||||
|
}
|
||||||
|
title
|
||||||
|
url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
#import "./Image.graphql"
|
||||||
#import "./PageLinks.graphql"
|
#import "./PageLinks.graphql"
|
||||||
|
|
||||||
fragment Hero on Hero {
|
fragment Hero on Hero {
|
||||||
@@ -5,12 +6,7 @@ fragment Hero on Hero {
|
|||||||
totalCount
|
totalCount
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
dimension {
|
...Image
|
||||||
height
|
|
||||||
width
|
|
||||||
}
|
|
||||||
title
|
|
||||||
url
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ fragment Image on SysAsset {
|
|||||||
width
|
width
|
||||||
}
|
}
|
||||||
metadata
|
metadata
|
||||||
title
|
|
||||||
url
|
|
||||||
system {
|
system {
|
||||||
uid
|
uid
|
||||||
}
|
}
|
||||||
|
title
|
||||||
|
url
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
fragment CurrentBlocksPageLink on CurrentBlocksPage {
|
fragment CurrentBlocksPageLink on CurrentBlocksPage {
|
||||||
|
system {
|
||||||
|
uid
|
||||||
|
}
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|
||||||
fragment TempPageLink on TempPage {
|
fragment TempPageLink on TempPage {
|
||||||
|
system {
|
||||||
|
uid
|
||||||
|
}
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
#import "../PageLinks.graphql"
|
#import "./Image.graphql"
|
||||||
|
#import "./PageLinks.graphql"
|
||||||
|
|
||||||
fragment PreambleBlock on CurrentBlocksPageBlocksPreamble {
|
fragment Preamble on CurrentBlocksPage {
|
||||||
preamble {
|
preamble {
|
||||||
text {
|
text {
|
||||||
json
|
json
|
||||||
embedded_itemsConnection(limit: 30) {
|
embedded_itemsConnection(limit: 30) {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
|
__typename
|
||||||
...CurrentBlocksPageLink
|
...CurrentBlocksPageLink
|
||||||
|
...Image
|
||||||
...TempPageLink
|
...TempPageLink
|
||||||
... on SysAsset {
|
|
||||||
title
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
|
#import "./Image.graphql"
|
||||||
#import "./PageLinks.graphql"
|
#import "./PageLinks.graphql"
|
||||||
|
|
||||||
fragment Puff on Puff {
|
fragment Puff on Puff {
|
||||||
imageConnection {
|
imageConnection {
|
||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
title
|
...Image
|
||||||
url
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -24,6 +24,9 @@ fragment Puff on Puff {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
system {
|
||||||
|
uid
|
||||||
|
}
|
||||||
text {
|
text {
|
||||||
json
|
json
|
||||||
embedded_itemsConnection {
|
embedded_itemsConnection {
|
||||||
@@ -31,10 +34,7 @@ fragment Puff on Puff {
|
|||||||
edges {
|
edges {
|
||||||
node {
|
node {
|
||||||
__typename
|
__typename
|
||||||
... on SysAsset {
|
...Image
|
||||||
title
|
|
||||||
url
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,10 +1,11 @@
|
|||||||
#import "../Fragments/Aside/Contact.graphql"
|
#import "../Fragments/Aside/Contact.graphql"
|
||||||
#import "../Fragments/Aside/Puff.graphql"
|
#import "../Fragments/Aside/Puff.graphql"
|
||||||
#import "../Fragments/Blocks/List.graphql"
|
#import "../Fragments/Blocks/List.graphql"
|
||||||
#import "../Fragments/Blocks/Preamble.graphql"
|
|
||||||
#import "../Fragments/Blocks/Puff.graphql"
|
#import "../Fragments/Blocks/Puff.graphql"
|
||||||
#import "../Fragments/Blocks/Text.graphql"
|
#import "../Fragments/Blocks/Text.graphql"
|
||||||
|
#import "../Fragments/Breadcrumbs.graphql"
|
||||||
#import "../Fragments/Hero.graphql"
|
#import "../Fragments/Hero.graphql"
|
||||||
|
#import "../Fragments/Preamble.graphql"
|
||||||
|
|
||||||
query GetCurrentBlockPage($locale: String!, $url: String!) {
|
query GetCurrentBlockPage($locale: String!, $url: String!) {
|
||||||
all_current_blocks_page(limit: 1, locale: $locale, where: { url: $url }) {
|
all_current_blocks_page(limit: 1, locale: $locale, where: { url: $url }) {
|
||||||
@@ -17,13 +18,14 @@ query GetCurrentBlockPage($locale: String!, $url: String!) {
|
|||||||
blocks {
|
blocks {
|
||||||
__typename
|
__typename
|
||||||
...ListBlock
|
...ListBlock
|
||||||
...PreambleBlock
|
|
||||||
...PuffBlock
|
...PuffBlock
|
||||||
...TextBlock
|
...TextBlock
|
||||||
}
|
}
|
||||||
|
...Breadcrumbs
|
||||||
hero {
|
hero {
|
||||||
...Hero
|
...Hero
|
||||||
}
|
}
|
||||||
|
...Preamble
|
||||||
title
|
title
|
||||||
url
|
url
|
||||||
}
|
}
|
||||||
|
|||||||
3
types/components/current/asides/puff.ts
Normal file
3
types/components/current/asides/puff.ts
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
import type { Puff } from "@/types/requests/puff"
|
||||||
|
|
||||||
|
export type PuffProps = Puff
|
||||||
8
types/components/current/breadcrumbs.ts
Normal file
8
types/components/current/breadcrumbs.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import type { Breadcrumb } from "@/types/requests/currentBlockPage"
|
||||||
|
import type { Edges, Node } from "@/types/requests/utils/edges"
|
||||||
|
|
||||||
|
export type BreadcrumbsProps = {
|
||||||
|
breadcrumbs: Edges<Breadcrumb>
|
||||||
|
parent?: Node<Breadcrumb>
|
||||||
|
title: string
|
||||||
|
}
|
||||||
10
types/components/current/preamble.ts
Normal file
10
types/components/current/preamble.ts
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import type { BreadcrumbsProps } from "./breadcrumbs"
|
||||||
|
import type { Preamble } from "@/types/requests/preamble"
|
||||||
|
|
||||||
|
export type PreambleProps = {
|
||||||
|
breadcrumbs: BreadcrumbsProps["breadcrumbs"]
|
||||||
|
breadcrumbParent: BreadcrumbsProps["parent"]
|
||||||
|
breadcrumbTitle: BreadcrumbsProps["title"]
|
||||||
|
preamble?: Preamble
|
||||||
|
title: string
|
||||||
|
}
|
||||||
8
types/components/current/subnavMobile.ts
Normal file
8
types/components/current/subnavMobile.ts
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
import type { Breadcrumb } from "@/types/requests/currentBlockPage"
|
||||||
|
import type { Edges, Node } from "@/types/requests/utils/edges"
|
||||||
|
|
||||||
|
export type SubnavMobileProps = {
|
||||||
|
breadcrumbs: Edges<Breadcrumb>
|
||||||
|
parent?: Node<Breadcrumb>
|
||||||
|
title: string
|
||||||
|
}
|
||||||
13
types/components/jsontohtml.ts
Normal file
13
types/components/jsontohtml.ts
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import type { RTENode } from "../rte/node"
|
||||||
|
|
||||||
|
import type { Node } from "@/types/requests/utils/edges";
|
||||||
|
import type { RenderOptions } from "../rte/option";
|
||||||
|
import type { Embeds } from "@/types/requests/embeds";
|
||||||
|
|
||||||
|
export type JsonToHtmlProps = {
|
||||||
|
embeds: Node<Embeds>[]
|
||||||
|
nodes: RTENode[]
|
||||||
|
renderOptions?: RenderOptions
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EmbedByUid = Record<string, Node<Embeds>>
|
||||||
@@ -1,8 +1,13 @@
|
|||||||
export type Image = {
|
export type Image = {
|
||||||
|
description?: string
|
||||||
dimension: {
|
dimension: {
|
||||||
height: number
|
height: number
|
||||||
width: number
|
width: number
|
||||||
}
|
}
|
||||||
|
metadata: JSON
|
||||||
|
system: {
|
||||||
|
uid: string
|
||||||
|
}
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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
|
|
||||||
>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +1,12 @@
|
|||||||
import type { RTERootObject } from "@/types/rte"
|
|
||||||
import type { SysAsset } from "../utils/asset"
|
|
||||||
import type { Edges } from "../utils/edges"
|
import type { Edges } from "../utils/edges"
|
||||||
import type { ExternalLink } from "../utils/externalLink"
|
import type { Embeds } from "../embeds"
|
||||||
import type { PageLink } from "../utils/pageLink"
|
import type { RTEDocument } from "@/types/rte/node"
|
||||||
|
|
||||||
export type Text = {
|
export type Text = {
|
||||||
text: {
|
text: {
|
||||||
content: {
|
content: {
|
||||||
json: RTERootObject
|
embedded_itemsConnection: Edges<Embeds>
|
||||||
embedded_itemsConnection: Edges<ExternalLink | PageLink | SysAsset>
|
json: RTEDocument
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import type { PuffAside } from "./asides/puff"
|
|||||||
import type { Hero } from "./hero"
|
import type { Hero } from "./hero"
|
||||||
import type { List } from "./blocks/list"
|
import type { List } from "./blocks/list"
|
||||||
import type { PuffBlock } from "./blocks/puff"
|
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 { Text } from "./blocks/text"
|
||||||
import type { AllRequestResponse } from "./utils/all"
|
import type { AllRequestResponse } from "./utils/all"
|
||||||
import type { AsideTypenameEnum, Typename } from "./utils/typename"
|
import type { AsideTypenameEnum, Typename } from "./utils/typename"
|
||||||
|
import type { EmbedEnum } from "./utils/embeds"
|
||||||
|
import type { Edges } from "./utils/edges"
|
||||||
|
|
||||||
export type Asides =
|
export type Asides =
|
||||||
| Typename<Contact, AsideTypenameEnum.CurrentBlocksPageAsideContact>
|
| Typename<Contact, AsideTypenameEnum.CurrentBlocksPageAsideContact>
|
||||||
@@ -16,14 +18,38 @@ export type Asides =
|
|||||||
|
|
||||||
export type Blocks =
|
export type Blocks =
|
||||||
| Typename<List, BlocksTypenameEnum.CurrentBlocksPageBlocksList>
|
| Typename<List, BlocksTypenameEnum.CurrentBlocksPageBlocksList>
|
||||||
| Typename<Preamble, BlocksTypenameEnum.CurrentBlocksPageBlocksPreamble>
|
|
||||||
| Typename<PuffBlock, BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs>
|
| Typename<PuffBlock, BlocksTypenameEnum.CurrentBlocksPageBlocksPuffs>
|
||||||
| Typename<Text, BlocksTypenameEnum.CurrentBlocksPageBlocksText>
|
| 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 = {
|
export type BlockPage = {
|
||||||
aside: Asides[]
|
aside: Asides[]
|
||||||
blocks: Blocks[]
|
blocks: Blocks[]
|
||||||
|
breadcrumbs: Breadcrumbs
|
||||||
hero: Hero
|
hero: Hero
|
||||||
|
preamble: Preamble
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|||||||
8
types/requests/embeds.ts
Normal file
8
types/requests/embeds.ts
Normal 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
|
||||||
@@ -1,16 +1,11 @@
|
|||||||
import type { AllRequestResponse } from "./utils/all"
|
import type { AllRequestResponse } from "./utils/all"
|
||||||
import type { Edges } from "./utils/edges"
|
import type { Edges } from "./utils/edges"
|
||||||
import { Asset } from "./utils/asset"
|
import type { Image } from "../image"
|
||||||
import { PageLink } from "./utils/pageLink"
|
import type { PageLink } from "./utils/pageLink"
|
||||||
|
|
||||||
type AppDownloadLink = {
|
|
||||||
title: string
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
type AppDownload = {
|
type AppDownload = {
|
||||||
href: string
|
href: string
|
||||||
imageConnection: Edges<Asset>
|
imageConnection: Edges<Image>
|
||||||
}
|
}
|
||||||
|
|
||||||
export type InternalLink = {
|
export type InternalLink = {
|
||||||
@@ -52,7 +47,7 @@ export type Footer = {
|
|||||||
app_store: AppDownload
|
app_store: AppDownload
|
||||||
google_play: AppDownload
|
google_play: AppDownload
|
||||||
}
|
}
|
||||||
logoConnection: Edges<Asset>
|
logoConnection: Edges<Image>
|
||||||
navigation: NavigationItem[]
|
navigation: NavigationItem[]
|
||||||
social_media: {
|
social_media: {
|
||||||
title: string
|
title: string
|
||||||
@@ -62,7 +57,7 @@ export type Footer = {
|
|||||||
}
|
}
|
||||||
trip_advisor: {
|
trip_advisor: {
|
||||||
title: string
|
title: string
|
||||||
logoConnection: Edges<Asset>
|
logoConnection: Edges<Image>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
10
types/requests/preamble.ts
Normal file
10
types/requests/preamble.ts
Normal 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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,13 +1,12 @@
|
|||||||
|
import type { Image } from "../image"
|
||||||
import type { Edges } from "./utils/edges"
|
import type { Edges } from "./utils/edges"
|
||||||
|
import type { Embeds } from "./embeds"
|
||||||
import type { ExternalLink } from "./utils/externalLink"
|
import type { ExternalLink } from "./utils/externalLink"
|
||||||
import type { PageLink } from "./utils/pageLink"
|
import type { PageLink } from "./utils/pageLink"
|
||||||
import type { Typename } from "./utils/typename"
|
import type { RTEDocument } from "../rte/node"
|
||||||
|
|
||||||
export type Puff = {
|
export type Puff = {
|
||||||
imageConnection: Edges<{
|
imageConnection: Edges<Image>
|
||||||
title: string
|
|
||||||
url: string
|
|
||||||
}>
|
|
||||||
is_internal: boolean
|
is_internal: boolean
|
||||||
link: {
|
link: {
|
||||||
href: string
|
href: string
|
||||||
@@ -15,12 +14,12 @@ export type Puff = {
|
|||||||
}
|
}
|
||||||
link_text?: string
|
link_text?: string
|
||||||
pageConnection: Edges<ExternalLink | PageLink>
|
pageConnection: Edges<ExternalLink | PageLink>
|
||||||
|
system: {
|
||||||
|
uid: string
|
||||||
|
}
|
||||||
text: {
|
text: {
|
||||||
json: JSON
|
embedded_itemsConnection: Edges<Embeds>
|
||||||
embedded_itemsConnection: Edges<Typename<{
|
json: RTEDocument
|
||||||
title: string
|
|
||||||
url: string
|
|
||||||
}, "SysAsset">>
|
|
||||||
}
|
}
|
||||||
title: string
|
title: string
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,5 @@
|
|||||||
|
import type { EmbedEnum } from "./embeds"
|
||||||
|
import type { Image } from "@/types/image"
|
||||||
import type { Typename } from "./typename"
|
import type { Typename } from "./typename"
|
||||||
|
|
||||||
export type Asset = {
|
export type SysAsset = Typename<Image, EmbedEnum.SysAsset>
|
||||||
title: string
|
|
||||||
url: string
|
|
||||||
}
|
|
||||||
|
|
||||||
export type SysAsset = Typename<Asset, "SysAsset">
|
|
||||||
|
|||||||
7
types/requests/utils/embeds.ts
Normal file
7
types/requests/utils/embeds.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export enum EmbedEnum {
|
||||||
|
CurrentBlocksPage = "CurrentBlocksPage",
|
||||||
|
SysAsset = "SysAsset",
|
||||||
|
TempPage = "TempPage",
|
||||||
|
}
|
||||||
|
|
||||||
|
export type Embed = keyof typeof EmbedEnum
|
||||||
@@ -1,5 +1,12 @@
|
|||||||
|
import type { EmbedEnum } from "./embeds"
|
||||||
|
import type { Typename } from "./typename"
|
||||||
|
|
||||||
export type ExternalLink = {
|
export type ExternalLink = {
|
||||||
__typename: "TempPage"
|
system: {
|
||||||
|
uid: string
|
||||||
|
}
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type ExternalLinkType = Typename<ExternalLink, EmbedEnum.TempPage>
|
||||||
|
|||||||
@@ -1,5 +1,12 @@
|
|||||||
|
import type { EmbedEnum } from "./embeds"
|
||||||
|
import type { Typename } from "./typename"
|
||||||
|
|
||||||
export type PageLink = {
|
export type PageLink = {
|
||||||
__typename: "CurrentBlocksPage"
|
system: {
|
||||||
|
uid: string
|
||||||
|
}
|
||||||
title: string
|
title: string
|
||||||
url: string
|
url: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type PageLinkType = Typename<PageLink, EmbedEnum.CurrentBlocksPage>
|
||||||
|
|||||||
@@ -1,8 +1,3 @@
|
|||||||
export const AsideTypenames = {
|
|
||||||
CurrentBlocksPageAsideContact: "CurrentBlocksPageAsideContact",
|
|
||||||
CurrentBlocksPageAsidePuff: "CurrentBlocksPageAsidePuff",
|
|
||||||
}
|
|
||||||
|
|
||||||
export enum AsideTypenameEnum {
|
export enum AsideTypenameEnum {
|
||||||
CurrentBlocksPageAsideContact = "CurrentBlocksPageAsideContact",
|
CurrentBlocksPageAsideContact = "CurrentBlocksPageAsideContact",
|
||||||
CurrentBlocksPageAsidePuff = "CurrentBlocksPageAsidePuff",
|
CurrentBlocksPageAsidePuff = "CurrentBlocksPageAsidePuff",
|
||||||
@@ -10,15 +5,6 @@ export enum AsideTypenameEnum {
|
|||||||
|
|
||||||
export type AsideTypename = keyof typeof 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 {
|
export enum BlocksTypenameEnum {
|
||||||
CurrentBlocksPageBlocksList = "CurrentBlocksPageBlocksList",
|
CurrentBlocksPageBlocksList = "CurrentBlocksPageBlocksList",
|
||||||
CurrentBlocksPageBlocksPreamble = "CurrentBlocksPageBlocksPreamble",
|
CurrentBlocksPageBlocksPreamble = "CurrentBlocksPageBlocksPreamble",
|
||||||
@@ -26,6 +12,8 @@ export enum BlocksTypenameEnum {
|
|||||||
CurrentBlocksPageBlocksText = "CurrentBlocksPageBlocksText",
|
CurrentBlocksPageBlocksText = "CurrentBlocksPageBlocksText",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type BlocksTypename = keyof typeof BlocksTypenameEnum
|
||||||
|
|
||||||
export type Typename<T, K> = T & {
|
export type Typename<T, K> = T & {
|
||||||
__typename: K
|
__typename: K
|
||||||
}
|
}
|
||||||
|
|||||||
58
types/rte.ts
58
types/rte.ts
@@ -1,58 +0,0 @@
|
|||||||
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
|
|
||||||
}
|
|
||||||
38
types/rte/attrs.ts
Normal file
38
types/rte/attrs.ts
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import { RTEItemTypeEnum } from "./enums"
|
||||||
|
import type { EmbedTypesEnum, RTEItemType } from "./enums"
|
||||||
|
import type { Lang } from "../lang"
|
||||||
|
|
||||||
|
export interface Attributes {
|
||||||
|
[key: string]: any
|
||||||
|
"class-name"?: string
|
||||||
|
type: RTEItemType
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTEAssetAttrs extends Attributes {
|
||||||
|
"alt": string
|
||||||
|
"asset-alt": string
|
||||||
|
"asset-link": string
|
||||||
|
"asset-name": string
|
||||||
|
"asset-type": "image/png" | "image/jpg" | "image/jpeg"
|
||||||
|
"asset-uid": string
|
||||||
|
"display-type": EmbedTypesEnum.display
|
||||||
|
"content-type-uid": "sys_assets"
|
||||||
|
"inline": false
|
||||||
|
"type": RTEItemTypeEnum.asset
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTEAnchorAttrs extends Attributes {
|
||||||
|
target: string
|
||||||
|
url: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTELinkAttrs extends Attributes {
|
||||||
|
'display-type': EmbedTypesEnum.link
|
||||||
|
'class-name': string
|
||||||
|
'content-type-uid': string
|
||||||
|
'entry-uid': string
|
||||||
|
locale: Lang
|
||||||
|
href: string
|
||||||
|
target: HTMLAnchorElement["target"]
|
||||||
|
type: RTEItemTypeEnum.entry
|
||||||
|
}
|
||||||
48
types/rte/enums.ts
Normal file
48
types/rte/enums.ts
Normal file
@@ -0,0 +1,48 @@
|
|||||||
|
export enum EmbedTypesEnum {
|
||||||
|
block = 'block',
|
||||||
|
display = 'display',
|
||||||
|
download = 'download',
|
||||||
|
inline = 'inline',
|
||||||
|
link = 'link',
|
||||||
|
}
|
||||||
|
|
||||||
|
export type EmbedTypes = keyof typeof EmbedTypesEnum
|
||||||
|
|
||||||
|
/** Copied from https://github.com/contentstack/contentstack-utils-javascript/blob/master/src/nodes/node-type.ts */
|
||||||
|
export enum RTETypeEnum {
|
||||||
|
a = "a",
|
||||||
|
blockquote = "blockquote",
|
||||||
|
code = "code",
|
||||||
|
doc = "doc",
|
||||||
|
embed = "embed",
|
||||||
|
h1 = "h1",
|
||||||
|
h2 = "h2",
|
||||||
|
h3 = "h3",
|
||||||
|
h4 = "h4",
|
||||||
|
h5 = "h5",
|
||||||
|
h6 = "h6",
|
||||||
|
hr = "hr",
|
||||||
|
img = "img",
|
||||||
|
li = "li",
|
||||||
|
ol = "ol",
|
||||||
|
p = "p",
|
||||||
|
reference = "reference",
|
||||||
|
table = "table",
|
||||||
|
tbody = "tbody",
|
||||||
|
td = "td",
|
||||||
|
text = "text",
|
||||||
|
tfoot = "tfoot",
|
||||||
|
th = "th",
|
||||||
|
thead = "thead",
|
||||||
|
tr = "tr",
|
||||||
|
ul = "ul",
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RTEType = keyof typeof RTETypeEnum
|
||||||
|
|
||||||
|
export enum RTEItemTypeEnum {
|
||||||
|
asset = "asset",
|
||||||
|
entry = "entry",
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RTEItemType = keyof typeof RTEItemTypeEnum
|
||||||
71
types/rte/node.ts
Normal file
71
types/rte/node.ts
Normal file
@@ -0,0 +1,71 @@
|
|||||||
|
import { RTETypeEnum } from "./enums"
|
||||||
|
import type { Attributes, RTEAnchorAttrs, RTEAssetAttrs, RTELinkAttrs } from "./attrs"
|
||||||
|
import type { EmbedByUid } from "../components/jsontohtml"
|
||||||
|
import type { RenderOptions } from "./option"
|
||||||
|
|
||||||
|
export interface RTEDefaultNode {
|
||||||
|
attrs: Attributes
|
||||||
|
children: RTENode[]
|
||||||
|
type: RTETypeEnum
|
||||||
|
uid: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTELinkNode {
|
||||||
|
attrs: Attributes
|
||||||
|
children: RTENode[]
|
||||||
|
type: RTETypeEnum
|
||||||
|
uid: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTEReferenceAssetNode extends RTEDefaultNode {
|
||||||
|
attrs: RTEAssetAttrs
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTEAnchorNode extends RTEDefaultNode {
|
||||||
|
attrs: RTEAnchorAttrs
|
||||||
|
type: RTETypeEnum.a
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RTEReferenceLinkNode extends RTEDefaultNode {
|
||||||
|
attrs: RTELinkAttrs
|
||||||
|
}
|
||||||
|
|
||||||
|
export enum RTEMarkType {
|
||||||
|
bold = "bold",
|
||||||
|
break = "break",
|
||||||
|
classnameOrId = "classnameOrId",
|
||||||
|
inlineCode = "inlineCode",
|
||||||
|
italic = "italic",
|
||||||
|
strikethrough = "strikethrough",
|
||||||
|
subscript = "subscript",
|
||||||
|
superscript = "superscript",
|
||||||
|
underline = "underline",
|
||||||
|
}
|
||||||
|
|
||||||
|
type RTETextNodeOptionalKeys = {
|
||||||
|
[key in RTEMarkType]?: boolean
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RTETextNode = RTETextNodeOptionalKeys & {
|
||||||
|
classname?: string
|
||||||
|
id?: string
|
||||||
|
text: string
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RTERegularNode = RTEDefaultNode | RTEAnchorNode
|
||||||
|
|
||||||
|
export type RTEReferenceNode = RTEDefaultNode | RTEAnchorNode
|
||||||
|
|
||||||
|
export type RTENode = RTERegularNode | RTEReferenceNode | RTETextNode
|
||||||
|
|
||||||
|
export type RTERenderMark = (children: React.ReactNode, classname?: string, id?: string) => JSX.Element
|
||||||
|
|
||||||
|
export interface RTEDocument extends RTEDefaultNode {
|
||||||
|
type: RTETypeEnum.doc
|
||||||
|
_version: number
|
||||||
|
}
|
||||||
|
|
||||||
|
export type RTERenderOptionComponent = (node: RTERegularNode, embeds: EmbedByUid, next: RTENext, fullRenderOptions: RenderOptions) => React.ReactNode
|
||||||
|
|
||||||
|
export type RTENext = (nodes: RTENode[], embeds: EmbedByUid, fullRenderOptions: RenderOptions) => string
|
||||||
|
|
||||||
5
types/rte/option.ts
Normal file
5
types/rte/option.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import type { RTERenderMark, RTERenderOptionComponent } from "./node"
|
||||||
|
|
||||||
|
export type RenderOptions = {
|
||||||
|
[type: string]: RTERenderOptionComponent | RTERenderMark
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user