Skip to content

Commit

Permalink
add heroHTML
Browse files Browse the repository at this point in the history
  • Loading branch information
twentytitus committed Jul 10, 2024
1 parent 8359fd3 commit 4af0dd1
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion components/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ import Image from 'next/image';
import { getAssetURL } from '../Util/getAssetURL';

type HeroProps = {
heroHTML: string | null;
heroTitle: string | null;
heroSubTitle: string | null;
heroImage: string;
};

export const Hero = ({ heroTitle, heroSubTitle, heroImage }: HeroProps) => {
export const Hero = ({ heroHTML, heroTitle, heroSubTitle, heroImage }: HeroProps) => {
const [imageLoaded, setImageLoaded] = useState(false);

return (
Expand All @@ -28,6 +29,12 @@ export const Hero = ({ heroTitle, heroSubTitle, heroImage }: HeroProps) => {
priority={true}
/>
</div>
{heroHTML && (
<div className={s.heroHTMLContainer}>
{heroHTML}
</div>
)}
</div>
{heroTitle && <h1 className={cN(s.title, s.titles)}>{heroTitle}</h1>}
{heroSubTitle && (
<h3 className={cN(s.subTitle, s.titles)}>{heroSubTitle}</h3>
Expand Down
1 change: 1 addition & 0 deletions components/Section/SectionWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type SectionWrapperProps = {
title?: string;
status?: Status;
hasHero?: boolean;
heroHTML?: string;
heroTitle?: string;
heroImage?: string;
anchor?: string;
Expand Down
1 change: 1 addition & 0 deletions pages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const PageWithSections = ({ page }: PageProps): ReactElement => {
<section>
{page.hasHero && page.heroImage && (
<Hero
heroHTML={page.heroHTML}
heroTitle={page.heroTitle}
heroSubTitle={page.heroSubTitle}
heroImage={page.heroImage}
Expand Down
1 change: 1 addition & 0 deletions pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const Start = ({ page }: PageProps): ReactElement => {
<>
{page.hasHero && page.heroImage && (
<Hero
heroHTML={page.heroHTML}
heroTitle={page.heroTitle}
heroSubTitle={page.heroSubTitle}
heroImage={page.heroImage}
Expand Down
6 changes: 6 additions & 0 deletions utils/getPageProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export type Page = {
title: string;
status: Status;
hasHero: boolean;
heroHTML: string | null;
heroTitle: string | null;
heroSubTitle: string | null;
heroImage: string | null;
Expand All @@ -34,6 +35,7 @@ type FetchedPage = {
title: string;
status: Status;
hasHero: boolean;
heroHTML: string | null;
heroTitle: string | null;
heroSubTitle: string | null;
heroImage: string | null;
Expand All @@ -48,6 +50,7 @@ const pageFields = [
'title',
'status',
'hasHero',
'heroHTML',
'heroTitle',
'heroSubTitle',
'heroImage',
Expand All @@ -69,6 +72,7 @@ type FetchedSectionData = {
includeAgs?: string[];
excludeAgs?: string[];
hasHero: boolean;
heroHTML?: string;
heroTitle?: string;
heroImage?: string;
elements: FetchedElement[];
Expand Down Expand Up @@ -232,6 +236,7 @@ const updatePageStructure = (
title: fetchedPage.title,
status: fetchedPage.status,
hasHero: fetchedPage.hasHero,
heroHTML: fetchedPage.heroHTML,
heroTitle: fetchedPage.heroTitle,
heroSubTitle: fetchedPage.heroSubTitle,
heroImage: fetchedPage.heroImage,
Expand All @@ -257,6 +262,7 @@ const updatePageStructure = (
includeAgs: section.item.includeAgs || [],
excludeAgs: section.item.excludeAgs || [],
hasHero: section.item.hasHero,
heroHTML: section.item.heroHTML,
heroTitle: section.item.heroTitle,
heroImage: section.item.heroImage,
render: section.item.elements
Expand Down

0 comments on commit 4af0dd1

Please sign in to comment.