From f9e2e49d8ae7f1525b5dc5cb3824b6f7d842b5f3 Mon Sep 17 00:00:00 2001 From: kimjaehyeon0101 <47347352-kimjaehyeon0101@users.noreply.replit.com> Date: Mon, 13 Oct 2025 09:09:28 +0000 Subject: [PATCH] Distinguish new media outlets from regular ones within categories Refactors `getOutletsByCategory` to `getSeparatedOutlets` in `MainContent.tsx`, separating outlets with recent articles (marked as "NEW") from regular ones and improving UI presentation. Replit-Commit-Author: Agent Replit-Commit-Session-Id: aabe2db1-f078-4501-aab5-be145ebc6b9a Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/3df548ff-50ae-432f-9be4-25d34eccc983/aabe2db1-f078-4501-aab5-be145ebc6b9a/ETDmxYB --- .replit | 4 ++ client/src/components/MainContent.tsx | 74 +++++++++++++++++++++++---- 2 files changed, 68 insertions(+), 10 deletions(-) diff --git a/.replit b/.replit index b94bf6b..027d7ac 100644 --- a/.replit +++ b/.replit @@ -38,6 +38,10 @@ externalPort = 3000 localPort = 43777 externalPort = 4200 +[[ports]] +localPort = 44067 +externalPort = 5000 + [env] PORT = "5000" diff --git a/client/src/components/MainContent.tsx b/client/src/components/MainContent.tsx index df444ec..4573700 100644 --- a/client/src/components/MainContent.tsx +++ b/client/src/components/MainContent.tsx @@ -54,20 +54,38 @@ export default function MainContent() { return acc; }, {} as Record); - // Group outlets by category and sort - const getOutletsByCategory = (category: string) => { + // Group outlets by category and separate NEW outlets from regular ones + const getSeparatedOutlets = (category: string) => { const filtered = allOutlets.filter(outlet => outlet.category.toLowerCase() === category.toLowerCase() ); - return filtered.sort((a, b) => { + // Separate outlets with articles (NEW) from those without + const newOutlets = filtered.filter(outlet => { + const articleCount = articleCountByOutlet[outlet.id] || 0; + return articleCount > 0; + }); + + const regularOutlets = filtered.filter(outlet => { + const articleCount = articleCountByOutlet[outlet.id] || 0; + return articleCount === 0; + }); + + // Sort both groups + const sortFn = (a: MediaOutlet, b: MediaOutlet) => { if (sortBy === "alphabetical") { return a.name.localeCompare(b.name); } else { // Sort by traffic score (descending - highest traffic first) return (b.trafficScore || 0) - (a.trafficScore || 0); } - }); + }; + + return { + newOutlets: newOutlets.sort(sortFn), + regularOutlets: regularOutlets.sort(sortFn), + total: filtered.length + }; }; const renderOutletCard = (outlet: MediaOutlet) => { @@ -199,10 +217,22 @@ export default function MainContent() {

People - ({getOutletsByCategory("People").length}) + ({getSeparatedOutlets("People").total})

- {getOutletsByCategory("People").map(renderOutletCard)} + {getSeparatedOutlets("People").newOutlets.length > 0 && ( + <> +
+ +

NEW

+
+ {getSeparatedOutlets("People").newOutlets.map(renderOutletCard)} + {getSeparatedOutlets("People").regularOutlets.length > 0 && ( +
+ )} + + )} + {getSeparatedOutlets("People").regularOutlets.map(renderOutletCard)}
@@ -210,10 +240,22 @@ export default function MainContent() {

Topics - ({getOutletsByCategory("Topics").length}) + ({getSeparatedOutlets("Topics").total})

- {getOutletsByCategory("Topics").map(renderOutletCard)} + {getSeparatedOutlets("Topics").newOutlets.length > 0 && ( + <> +
+ +

NEW

+
+ {getSeparatedOutlets("Topics").newOutlets.map(renderOutletCard)} + {getSeparatedOutlets("Topics").regularOutlets.length > 0 && ( +
+ )} + + )} + {getSeparatedOutlets("Topics").regularOutlets.map(renderOutletCard)}
@@ -221,10 +263,22 @@ export default function MainContent() {

Companies - ({getOutletsByCategory("Companies").length}) + ({getSeparatedOutlets("Companies").total})

- {getOutletsByCategory("Companies").map(renderOutletCard)} + {getSeparatedOutlets("Companies").newOutlets.length > 0 && ( + <> +
+ +

NEW

+
+ {getSeparatedOutlets("Companies").newOutlets.map(renderOutletCard)} + {getSeparatedOutlets("Companies").regularOutlets.length > 0 && ( +
+ )} + + )} + {getSeparatedOutlets("Companies").regularOutlets.map(renderOutletCard)}