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 446c29f
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 3 deletions.
11 changes: 9 additions & 2 deletions components/Hero/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,18 @@ import Image from 'next/image';
import { getAssetURL } from '../Util/getAssetURL';

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

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 +34,7 @@ export const Hero = ({ heroTitle, heroSubTitle, heroImage }: HeroProps) => {
priority={true}
/>
</div>
{heroHTML && <div className={s.heroHTMLContainer}>{heroHTML}</div>}
{heroTitle && <h1 className={cN(s.title, s.titles)}>{heroTitle}</h1>}
{heroSubTitle && (
<h3 className={cN(s.subTitle, s.titles)}>{heroSubTitle}</h3>
Expand Down
2 changes: 2 additions & 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 All @@ -26,6 +27,7 @@ export const SectionWrapper = ({
title,
status,
hasHero,
heroHTML,
heroTitle,
heroImage,
anchor,
Expand Down
2 changes: 2 additions & 0 deletions components/Section/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ export type Section = {
includeAgs: string[];
excludeAgs: string[];
hasHero: boolean;
heroHTML?: string;
heroTitle?: string;
heroImage?: string;
render: SectionElement[];
Expand Down Expand Up @@ -184,6 +185,7 @@ export const Section = ({
status={modifiedSection.status}
hasHero={modifiedSection.hasHero}
heroImage={modifiedSection.heroImage}
heroHTML={modifiedSection.heroHTML}
heroTitle={modifiedSection.heroTitle}
anchor={modifiedSection.anchor}
isFirstSection={isFirstSection}
Expand Down
3 changes: 2 additions & 1 deletion pages/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ const PageWithSections = ({ page }: PageProps): ReactElement => {
}
return (
<section>
{page.hasHero && page.heroImage && (
{page.hasHero && (page.heroImage || page.heroHTML) && (
<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 446c29f

Please sign in to comment.