diff --git a/src/app/api/prompts/route.ts b/src/app/api/prompts/route.ts index 354c6da14c7..7d06f6f2926 100644 --- a/src/app/api/prompts/route.ts +++ b/src/app/api/prompts/route.ts @@ -330,11 +330,17 @@ export async function GET(request: Request) { } if (tag) { - where.tags = { - some: { - tag: { slug: tag }, - }, - }; + // Handle multiple tags (comma-separated) + const tagSlugs = tag.split(",").map(t => t.trim()).filter(Boolean); + if (tagSlugs.length > 0) { + where.AND = tagSlugs.map(slug => ({ + tags: { + some: { + tag: { slug }, + }, + }, + })); + } } if (q) { diff --git a/src/app/prompts/page.tsx b/src/app/prompts/page.tsx index 4227390d58a..c43d21a3b9a 100644 --- a/src/app/prompts/page.tsx +++ b/src/app/prompts/page.tsx @@ -219,14 +219,21 @@ export default async function PromptsPage({ searchParams }: PromptsPageProps) { where.categoryId = params.category; } + // Handle tag parameter (can be comma-separated for multiple tags) if (params.tag) { - where.tags = { - some: { - tag: { - slug: params.tag, + // Handle multiple tags (comma-separated) + const tagSlugs = params.tag.split(",").map(t => t.trim()).filter(Boolean); + if (tagSlugs.length > 0) { + where.AND = tagSlugs.map(slug => ({ + tags: { + some: { + tag: { + slug, + }, + }, }, - }, - }; + })); + } } // Build order by clause diff --git a/src/components/prompts/infinite-prompt-list.tsx b/src/components/prompts/infinite-prompt-list.tsx index 67e0087682f..0796dcf7645 100644 --- a/src/components/prompts/infinite-prompt-list.tsx +++ b/src/components/prompts/infinite-prompt-list.tsx @@ -20,7 +20,7 @@ interface InfinitePromptListProps { type?: string; category?: string; categorySlug?: string; - tag?: string; + tag?: string; sort?: string; }; } diff --git a/src/components/prompts/prompt-filters.tsx b/src/components/prompts/prompt-filters.tsx index 41f92a985d0..58aa99d71ef 100644 --- a/src/components/prompts/prompt-filters.tsx +++ b/src/components/prompts/prompt-filters.tsx @@ -81,6 +81,8 @@ export function PromptFilters({ categories, tags, currentFilters, aiSearchEnable router.push("/prompts"); }; + const selectedTags = currentFilters.tag ? currentFilters.tag.split(",").filter(Boolean) : []; + const hasFilters = currentFilters.q || currentFilters.type || currentFilters.category || currentFilters.tag || currentFilters.sort; const activeFilterCount = [currentFilters.type, currentFilters.category, currentFilters.tag, currentFilters.sort && currentFilters.sort !== "newest"].filter(Boolean).length; @@ -318,25 +320,34 @@ export function PromptFilters({ categories, tags, currentFilters, aiSearchEnable />