diff --git a/app/(marketing)/trending/page.tsx b/app/(marketing)/trending/page.tsx index 14b7513..977a926 100644 --- a/app/(marketing)/trending/page.tsx +++ b/app/(marketing)/trending/page.tsx @@ -30,7 +30,25 @@ function updated(iso: string): string { return new Date(iso).toLocaleDateString("en-US", { month: "short", day: "numeric", timeZone: "UTC" }); } +type VotedSearch = { phrase: string; votes: number }; + +// Searches people voted on at pit.world. An extra, so any failure just hides it. +async function votedSearches(): Promise { + try { + const res = await fetch("https://pit.world/api/voted-searches?limit=20", { + next: { revalidate: 3600 }, + signal: AbortSignal.timeout(5_000), + }); + if (!res.ok) return []; + const body = (await res.json()) as { topics?: VotedSearch[] }; + return Array.isArray(body.topics) ? body.topics : []; + } catch { + return []; + } +} + export default async function TrendingPage() { + const voted = await votedSearches(); const topics = await currentTrends(serviceClient(), { limit: LIMIT, includeStale: true }); const newest = topics.reduce( (latest, topic) => (!latest || (topic.ingestedAt ?? "") > latest ? (topic.ingestedAt ?? latest) : latest), @@ -94,6 +112,23 @@ export default async function TrendingPage() { )} + {voted.length > 0 && ( +
+

Most voted searches on pit.world

+

+ Searches people cared enough about to vote on their results, this week. +

+
    + {voted.map((search) => ( +
  • + {search.phrase} + {search.votes} +
  • + ))} +
+
+ )} +

Run ads where these subjects are read