diff --git a/src/components/Tags/Tags.tsx b/src/components/Tags/Tags.tsx index 7c5e4e1..c5ce181 100644 --- a/src/components/Tags/Tags.tsx +++ b/src/components/Tags/Tags.tsx @@ -1,16 +1,40 @@ +import { addTopicsToQuery } from '@/utils/search.utils' import { Tag } from '@acid-info/lsd-react' import styled from '@emotion/styled' +import { useRouter } from 'next/router' -const Tags = ({ tags }: { tags: string[] }) => - tags.length > 0 ? ( +const Tags = ({ tags }: { tags: string[] }) => { + const router = useRouter() + + const onTagClick = (e: React.MouseEvent, tag: string) => { + e.preventDefault() + router.push( + { + pathname: '/search', + query: { + ...addTopicsToQuery([tag]), + }, + }, + undefined, + { shallow: true }, + ) + } + + return tags.length > 0 ? ( {tags.map((tag) => ( - + onTagClick(e, tag)} + size="small" + disabled={false} + key={tag} + > {tag} ))} ) : null +} const TagContainer = styled.div` display: flex;