diff --git a/src/app/api/prompts/route.ts b/src/app/api/prompts/route.ts index 26eb7a6f..26b32814 100644 --- a/src/app/api/prompts/route.ts +++ b/src/app/api/prompts/route.ts @@ -335,11 +335,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 fdb8b6f8..d2c29661 100644 --- a/src/app/prompts/page.tsx +++ b/src/app/prompts/page.tsx @@ -242,14 +242,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 6faae0a4..9dd2501e 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 150340df..bebd4ea1 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 />