diff --git a/lib/contentful/client.ts b/lib/contentful/client.ts index 9328bee4..ae96f542 100644 --- a/lib/contentful/client.ts +++ b/lib/contentful/client.ts @@ -72,6 +72,7 @@ export async function getPastShows( if (filter.length == 0) { const { items } = await client.getEntries({ "fields.mixcloudLink[exists]": true, + "fields.coverImage[exists]": true, "fields.date[lte]": now, order: "-fields.date,fields.title", content_type: "show", diff --git a/lib/contentful/pages/radio.ts b/lib/contentful/pages/radio.ts index 16303d49..53c27e36 100644 --- a/lib/contentful/pages/radio.ts +++ b/lib/contentful/pages/radio.ts @@ -12,6 +12,15 @@ import { sort, } from "../../../util"; +const placeholderImage = { + sys: { id: "4njwdSvfwFLNoSZ6j1jE2G" }, + title: "", + description: "", + url: "/images/placeholder.jpg", + width: 2000, + height: 1340, +}; + export const RADIO_SHOWS_PAGE_SIZE = 20; export async function getRadioPageSingle(slug: string, preview: boolean) { @@ -83,6 +92,10 @@ export async function getRadioPageSingle(slug: string, preview: boolean) { throw new Error(`No Show found for slug '${slug}'`); } + if (!entry.coverImage) { + entry.coverImage = placeholderImage; + } + console.log(entry.genresCollection); const genres = entry.genresCollection.items.map((genre) => genre?.name); @@ -247,7 +260,9 @@ export async function getRelatedShows( date: show.date, slug: show.slug, mixcloudLink: show.mixcloudLink, - coverImage: show.coverImage.url, + coverImage: show.coverImage?.url + ? show.coverImage.url + : placeholderImage.url, genres: show.genresCollection.items .map((genre) => genre?.name) .filter(Boolean), diff --git a/pages/radio/[slug].tsx b/pages/radio/[slug].tsx index 6be2aa03..dcbd787f 100644 --- a/pages/radio/[slug].tsx +++ b/pages/radio/[slug].tsx @@ -31,7 +31,7 @@ export default function Show({ ); } -export async function getStaticProps({ params, preview = false }) { +export async function getStaticProps({ params, preview = true }) { return { props: { preview, ...(await getRadioPageSingle(params.slug, preview)) }, }; diff --git a/views/radio/showBody.tsx b/views/radio/showBody.tsx index 513c7ca6..bd0d2b3a 100644 --- a/views/radio/showBody.tsx +++ b/views/radio/showBody.tsx @@ -71,7 +71,7 @@ export default function ShowBody({

- + {date && }

@@ -80,22 +80,26 @@ export default function ShowBody({
-
    - {genres.map((genre, i) => ( -
  • - - - -
  • - ))} -
+ {genres.length > 0 && ( +
    + {genres.map((genre, i) => ( +
  • + + + +
  • + ))} +
+ )}
-

With {persons}

+ {artists.length > 0 && ( +

With {persons}

+ )}
@@ -110,7 +114,7 @@ export default function ShowBody({
- {documentToReactComponents(content?.json)} + {content && {documentToReactComponents(content?.json)}}