From 6c999ba481b2d49d6db2c058f582ad8a503a6524 Mon Sep 17 00:00:00 2001 From: Rui Sousa <149320958+rccsousa@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:04:32 +0100 Subject: [PATCH] fix: update highlighted content pipeline (#61) why: - changes made to `highlights` data structure broke the currently deployed version of the content-hub as fetchers are fetching fields that no longer exist; how: - updates destructuring to include the new data structure of highlighted content which includes the `relationTo` and `value` fields --- src/Globals/HubHighlights/config.ts | 4 +-- src/app/_blocks/HubHead/Highlights/index.tsx | 9 ++++--- src/payload-types.ts | 28 ++++++++++++++++++-- 3 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/Globals/HubHighlights/config.ts b/src/Globals/HubHighlights/config.ts index e9e6ece..0f75a68 100644 --- a/src/Globals/HubHighlights/config.ts +++ b/src/Globals/HubHighlights/config.ts @@ -10,13 +10,13 @@ export const HomePageSettings: GlobalConfig = { name: "mainHighlight", label: "Main Highlight", type: "relationship", - relationTo: "blogposts", + relationTo: ["blogposts", 'podcasts', 'talks-and-roundtables'], }, { name: "secondaryHighlight", label: "Secondary Highlight", type: "relationship", - relationTo: "blogposts", + relationTo: ["blogposts", 'podcasts', 'talks-and-roundtables'], }, ], } diff --git a/src/app/_blocks/HubHead/Highlights/index.tsx b/src/app/_blocks/HubHead/Highlights/index.tsx index 103eb1f..513191b 100644 --- a/src/app/_blocks/HubHead/Highlights/index.tsx +++ b/src/app/_blocks/HubHead/Highlights/index.tsx @@ -5,6 +5,7 @@ import { formatDateTime } from "../../../_utilities/formatDateTime"; import styles from "./styles.module.css"; import { AuthorPill } from '@/app/_components/AuthorPill' import Link from "next/link"; +import ArchiveButton from "@/app/_components/ArchiveButton"; const placeholder = { title: "Placeholder", @@ -18,8 +19,8 @@ export async function Highlights({ content, main }) { content = placeholder; } - const { title, publishedAt, categories, authors } = content; - + const { title, publishedAt, categories, authors, slug } = content.value; + const contentType = content.relationTo return ( <> @@ -27,8 +28,8 @@ export async function Highlights({ content, main }) { className={`${styles.highlights} ${main ? styles.mainHighlight : styles.secondaryHighlight}`} >

HIGHLIGHTS

- {/* TODO: Adapt to other types of content as well */} - + +
{title}
{content === placeholder ? (
Please setup the highlights
) : ( diff --git a/src/payload-types.ts b/src/payload-types.ts index 1a2f257..a759f69 100644 --- a/src/payload-types.ts +++ b/src/payload-types.ts @@ -466,8 +466,32 @@ export interface Social { */ export interface HomepageSetting { id: string; - mainHighlight?: (string | null) | Blogpost; - secondaryHighlight?: (string | null) | Blogpost; + mainHighlight?: + | ({ + relationTo: 'blogposts'; + value: string | Blogpost; + } | null) + | ({ + relationTo: 'podcasts'; + value: string | Podcast; + } | null) + | ({ + relationTo: 'talks-and-roundtables'; + value: string | TalksAndRoundtable; + } | null); + secondaryHighlight?: + | ({ + relationTo: 'blogposts'; + value: string | Blogpost; + } | null) + | ({ + relationTo: 'podcasts'; + value: string | Podcast; + } | null) + | ({ + relationTo: 'talks-and-roundtables'; + value: string | TalksAndRoundtable; + } | null); updatedAt?: string | null; createdAt?: string | null; }