From 0e63fb40e78d6497fad081de72594d6f8ca37eb5 Mon Sep 17 00:00:00 2001 From: Devesh S Date: Thu, 23 Jul 2026 11:32:41 +0530 Subject: [PATCH] ui: add trending tags and implement dynamic hashtag auto-detection --- src/pages/Community/Community.tsx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pages/Community/Community.tsx b/src/pages/Community/Community.tsx index a4e087d..9109bc6 100644 --- a/src/pages/Community/Community.tsx +++ b/src/pages/Community/Community.tsx @@ -11,7 +11,7 @@ import { CONFESSIONS_DATA } from '@/constants'; type Tab = 'qa' | 'confession'; -const TRENDING_TAGS = ['hostel', 'academics', 'clubs', 'campus', 'canteen', 'sports', 'placement', 'library']; +const TRENDING_TAGS = ['hostel', 'academics', 'clubs', 'campus', 'canteen', 'sports', 'placement', 'library', 'cat exam', 'semester', 'labs', 'exams']; const AVATARS: Record = { 'Priya S.': 'https://images.unsplash.com/photo-1494790108377-be9c29b29330?auto=format&fit=crop&w=120&h=120&q=80', @@ -234,11 +234,17 @@ export default function Community() { const displayAuthor = authorName.trim() || 'Anonymous'; + // Auto-detect hashtags based on question text content + const detectedTags = TRENDING_TAGS.filter(tag => + questionText.toLowerCase().includes(tag.toLowerCase()) + ); + const finalTags = detectedTags.length > 0 ? detectedTags : ['fresher', 'general']; + const newQuestion = { title: questionText.split('\n')[0].substring(0, 100) || "Q&A Question", body: questionText, author: displayAuthor, - tags: ['fresher', 'general'], + tags: finalTags, upvotes: 0, isAnswered: false, createdAt: new Date().toISOString(),