Skip to content

Commit

Permalink
Merge pull request #114 from jamesqquick/add-tag-pages
Browse files Browse the repository at this point in the history
✨  tag pages display correctly
  • Loading branch information
ahaywood authored Oct 27, 2023
2 parents 6787446 + df28858 commit e3e073c
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 5 deletions.
2 changes: 1 addition & 1 deletion remix/api/metafile.css.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion remix/api/metafile.js.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion remix/api/metafile.server.json

Large diffs are not rendered by default.

17 changes: 16 additions & 1 deletion remix/app/queries/Queries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,21 @@ export const settingsQuery = groq`*[_type == "siteSettings"] {

export const TagsQuery = groq`*[_type == "category"] {_id, title, slug}`;

export const TagQuery = groq`*[_type == "category" && slug.current == $slug ] {
_id,
title,
description,
"episodes": *[_type=='episode' && references(^._id)] {
title,
categories[]->,
episodeNumber,
slug,
publishedAt,
briefDescription,
audioPath
}
}[0]`;

export const HostDetailsQuery = groq`*[_type == "siteSettings"] {AmySocialMedia, JamesSocialMedia}[0]`;

export const CurrentlyRecordingQuery = groq`*[_type == "siteSettings"] {currentlyRecording, recordingOnYouTube, recordingOnTwitch}[0]`;
Expand Down Expand Up @@ -222,4 +237,4 @@ export const SponsorsQuery = groq`*[_type == "sponsor" && published == true && p
offerLink,
aboutText,
founding,
}`;
}`;
42 changes: 41 additions & 1 deletion remix/app/routes/_interior.tag.$slug/route.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
import { redirect, type LoaderArgs } from '@remix-run/node';
import { useLoaderData } from '@remix-run/react';
import { EpisodeGrid } from '~/components/EpisodeGrid/EpisodeGrid';
import { Newsletter } from '~/components/Newsletter';
import { VerticalDivider } from '~/components/VerticalDivider';
import { getClient } from '~/lib/sanity';
import { TagQuery } from '~/queries/Queries';

export const loader = async ({ params }: LoaderArgs) => {
const slug = params.slug;
const sanityClient = getClient();
const content = await sanityClient.fetch(TagQuery, { slug });
//Todo: do we have a preferred solution for a page that doesn't exist?
if (!content) return redirect('/');

return { content, slug };
};

export default function Tag() {
return <div>Tags</div>;
const { content } = useLoaderData();

const { title, episodes } = content;

return (
<div>
<h3 className="text-center text-2xl italic uppercase">Tagged</h3>
{title && (
<h1 className="text-white text-center font-sans text-[60px] md:text-[85px] font-black leading-none m-0 p-0 relative z-episodeTitle">
{title}
</h1>
)}
{episodes ? (
<EpisodeGrid episodes={episodes} header={''} />
) : (
<p>
<em>No Episodes Found</em>
</p>
)}
<VerticalDivider />
<Newsletter />
</div>
);
}

1 comment on commit e3e073c

@vercel
Copy link

@vercel vercel bot commented on e3e073c Oct 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.