Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow show page to only have title field #142

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions lib/contentful/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ export async function getPastShows(
if (filter.length == 0) {
const { items } = await client.getEntries<TypeShowFields>({
"fields.mixcloudLink[exists]": true,
"fields.coverImage[exists]": true,
"fields.date[lte]": now,
order: "-fields.date,fields.title",
content_type: "show",
Expand Down
17 changes: 16 additions & 1 deletion lib/contentful/pages/radio.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 1 addition & 1 deletion pages/radio/[slug].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)) },
};
Expand Down
34 changes: 19 additions & 15 deletions views/radio/showBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function ShowBody({
<div className="h-3 block md:hidden" />

<p className="text-small text-center">
<Date dateString={date} />
{date && <Date dateString={date} />}
</p>

<div className="h-6" />
Expand All @@ -80,22 +80,26 @@ export default function ShowBody({

<div className="h-6" />

<ul className="w-full flex flex-wrap justify-center gap-2">
{genres.map((genre, i) => (
<li className="cursor-pointer" key={i}>
<Link
href={`/radio?genre=${encodeURIComponent(genre)}#shows`}
legacyBehavior
>
<Badge as="a" text={genre} />
</Link>
</li>
))}
</ul>
{genres.length > 0 && (
<ul className="w-full flex flex-wrap justify-center gap-2">
{genres.map((genre, i) => (
<li className="cursor-pointer" key={i}>
<Link
href={`/radio?genre=${encodeURIComponent(genre)}#shows`}
legacyBehavior
>
<Badge as="a" text={genre} />
</Link>
</li>
))}
</ul>
)}

<div className="h-6" />

<p className="font-medium text-center">With {persons}</p>
{artists.length > 0 && (
<p className="font-medium text-center">With {persons}</p>
)}
</div>

<div className="flex">
Expand All @@ -110,7 +114,7 @@ export default function ShowBody({

<div className="h-6" />

<Prose>{documentToReactComponents(content?.json)}</Prose>
{content && <Prose>{documentToReactComponents(content?.json)}</Prose>}
</div>
</section>
</Fragment>
Expand Down
Loading