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 />
- {filteredTags.filter((tag) => tag.id && tag.slug).map((tag) => ( - - ))} + onClick={() => { + let newTags: string[]; + if (isSelected) { + // Remove tag + newTags = selectedTags.filter(t => t !== tag.slug); + } else { + // Add tag + newTags = [...selectedTags, tag.slug]; + analyticsSearch.filter("tag", tag.slug); + } + updateFilter("tag", newTags.length > 0 ? newTags.join(",") : null); + }} + > + {tag.name} + + ); + })} {filteredTags.length === 0 && tagSearch && ( {t("search.noResults")} )} diff --git a/src/lib/plugins/widgets/coderabbit.ts b/src/lib/plugins/widgets/coderabbit.ts index 6942ba7d941..279eadcc59c 100644 --- a/src/lib/plugins/widgets/coderabbit.ts +++ b/src/lib/plugins/widgets/coderabbit.ts @@ -76,9 +76,10 @@ Provide your review in a clear, actionable format with specific line references } // Inject when tag includes "code", "debug", "git" - if (filters?.tag) { - const tag = filters.tag.toLowerCase(); - if (tag.includes("code") || tag.includes("debug") || tag.includes("git")) { + const tagParam = filters?.tag; + if (tagParam) { + const tagList = tagParam.toLowerCase(); + if (tagList.includes("code") || tagList.includes("debug") || tagList.includes("git")) { return true; } } diff --git a/src/lib/plugins/widgets/types.ts b/src/lib/plugins/widgets/types.ts index c2f40a77930..9f7c7310555 100644 --- a/src/lib/plugins/widgets/types.ts +++ b/src/lib/plugins/widgets/types.ts @@ -10,7 +10,7 @@ export interface WidgetContext { type?: string; category?: string; categorySlug?: string; - tag?: string; + tag?: string; sort?: string; }; page?: number;