diff --git a/src/components/TrendsSidebar.tsx b/src/components/TrendsSidebar.tsx index 3e32e93..d895437 100644 --- a/src/components/TrendsSidebar.tsx +++ b/src/components/TrendsSidebar.tsx @@ -10,17 +10,6 @@ interface Article { published_at: string | null; } -function ago(iso: string | null): string { - if (!iso) return "just now"; - const t = Date.now() - new Date(iso).getTime(); - const m = Math.floor(t / 60000); - if (m < 60) return `${m}m ago`; - return `${Math.floor(m / 60)}h ago`; -} - -// Tiny inline entity extractor: count tag occurrences in recent vs older -// articles and surface the top 5 by lift. Not vector — just keyword -// salience. Phase 6b will replace with pgvector semantic similarity. function detectTrends(recent: Article[], baseline: Article[]) { const recentCounts: Record = {}; for (const a of recent) for (const t of a.tags || []) { @@ -39,8 +28,11 @@ function detectTrends(recent: Article[], baseline: Article[]) { return { entity: k, lift, count: c }; }); scored.sort((a, b) => b.lift - a.lift); - const top = scored.slice(0, 5); - return top; + return scored.slice(0, 5); +} + +function titleCase(s: string): string { + return s.replace(/\b\w/g, (c) => c.toUpperCase()); } export default async function TrendsSidebar() { @@ -55,7 +47,7 @@ export default async function TrendsSidebar() { const since7d = new Date(Date.now() - 7 * 86400000).toISOString(); const since30d = new Date(Date.now() - 30 * 86400000).toISOString(); - const [recent, baseline, total] = await Promise.all([ + const [recent, baseline] = await Promise.all([ sb .from("wp_imported_posts") .select("title, excerpt, tags, wp_published_at") @@ -71,7 +63,6 @@ export default async function TrendsSidebar() { .lt("wp_published_at", since7d) .order("wp_published_at", { ascending: false }) .limit(800), - sb.from("wp_imported_posts").select("wp_id", { count: "exact", head: true }).eq("status", "published"), ]); const recentArts: Article[] = (recent.data || []).map((r: any) => ({ @@ -82,47 +73,37 @@ export default async function TrendsSidebar() { })); const trends = detectTrends(recentArts, baselineArts); - const nowIso = new Date().toISOString(); - return ( ); } diff --git a/src/styles/redesign-tokens.css b/src/styles/redesign-tokens.css index fe5172c..7ed1aef 100644 --- a/src/styles/redesign-tokens.css +++ b/src/styles/redesign-tokens.css @@ -24,6 +24,10 @@ --color-text-warning: #f59e0b; --color-text-danger: #ef4444; + /* Trends sidebar palette (Ryan, 2026-05-15) */ + --color-trends-bg: #F5EFEB; + --color-trends-text: #2F4F5B; + /* Type families */ --font-serif: Georgia, "Times New Roman", "Tinos", serif; --font-mono: "JetBrains Mono", "Fira Code", "Courier New", Courier, monospace;