diff --git a/lib/contentful/pages/home.ts b/lib/contentful/pages/home.ts index 3fa51c0..ceb9a48 100644 --- a/lib/contentful/pages/home.ts +++ b/lib/contentful/pages/home.ts @@ -35,7 +35,7 @@ export async function getHomePage() { latestArticles: articleCollection( order: date_DESC where: { isFeatured: false } - limit: 6 + limit: 20 ) { items { ...ArticlePreviewFragment @@ -56,6 +56,34 @@ export async function getHomePage() { const data = await graphql(HomePageQuery); + let latestArticles = extractCollection( + data, + "latestArticles" + ); + let icymi = false; + let bs = false; + + const filteredArticles = latestArticles.filter((article) => { + if (article.title.includes("ICYMI")) { + if (!icymi) { + icymi = true; + return true; + } + return false; + } else if (article.title.includes("Berlin Stories")) { + if (!bs) { + bs = true; + return true; + } + return false; + } + return true; + }); + + // latestArticles.filter(article => { + // return article.title.includes("Berlin Stories") && !icymi + // }) + return { featuredArticles: extractCollection( data, @@ -63,7 +91,7 @@ export async function getHomePage() { ), featuredShows: extractPage(data, "pageHome") .featuredShowsCollection.items, - latestArticles: extractCollection(data, "latestArticles"), + latestArticles: filteredArticles.slice(0, 6), nextUp: extractPage(data, "nextUp"), }; } diff --git a/views/home/latestNews.tsx b/views/home/latestNews.tsx index 6580341..6b61687 100644 --- a/views/home/latestNews.tsx +++ b/views/home/latestNews.tsx @@ -3,12 +3,16 @@ import ArticlePreview from "../../components/articlePreview"; import Pill from "../../components/pill"; import { Arrow } from "../../icons/arrow"; import { ArticleInterface } from "../../types/shared"; +import { useState } from "react"; export default function LatestNews({ articles, }: { articles: ArticleInterface[]; }) { + const [icymi, setIcymi] = useState(false); + const [bs, setBs] = useState(false); + return (