From 01646ebcb7175a804653bb3fa83d50f40d51d0b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E3=81=BF=E3=81=A6=E3=82=8B=E3=81=9E?= Date: Thu, 29 Jan 2026 07:32:13 +0900 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=88=A5=E5=90=8D=E3=82=BF=E3=82=B0?= =?UTF-8?q?=E3=82=92=E3=82=B5=E3=82=B8=E3=82=A7=E3=82=B9=E3=83=88=E3=81=AB?= =?UTF-8?q?=E5=B1=95=E9=96=8B=EF=BC=88#28=EF=BC=89=20(#244)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #28 件数 0 件除外をついでに対応(フロントのみ;バックエンドは後で対応) #28 Co-authored-by: miteruzo Reviewed-on: https://git.miteruzo.com/miteruzo/btrc-hub/pulls/244 --- frontend/src/components/PostFormTagsArea.tsx | 3 ++- frontend/src/components/TagLink.tsx | 7 +++++++ frontend/src/components/TagSearch.tsx | 5 +++-- frontend/src/components/TagSearchBox.tsx | 4 ++-- frontend/src/types.ts | 13 +++++++------ 5 files changed, 21 insertions(+), 11 deletions(-) diff --git a/frontend/src/components/PostFormTagsArea.tsx b/frontend/src/components/PostFormTagsArea.tsx index 38ffd70..de97ada 100644 --- a/frontend/src/components/PostFormTagsArea.tsx +++ b/frontend/src/components/PostFormTagsArea.tsx @@ -60,7 +60,8 @@ export default (({ tags, setTags }: Props) => { const { start, end, token } = getTokenAt (v, pos) setBounds ({ start, end }) const res = await axios.get (`${ API_BASE_URL }/tags/autocomplete`, { params: { q: token } }) - setSuggestions (toCamel (res.data as any, { deep: true }) as Tag[]) + const data = toCamel (res.data as any, { deep: true }) as Tag[] + setSuggestions (data.filter (t => t.postCount > 0)) setSuggestionsVsbl (suggestions.length > 0) } diff --git a/frontend/src/components/TagLink.tsx b/frontend/src/components/TagLink.tsx index a9a1c11..3ef86c8 100644 --- a/frontend/src/components/TagLink.tsx +++ b/frontend/src/components/TagLink.tsx @@ -91,6 +91,13 @@ export default (({ tag, style={{ paddingLeft: `${ (nestLevel - 1) }rem` }}> ↳ )} + {tag.matchedAlias != null && ( + <> + + {tag.matchedAlias} + + <> → + )} {linkFlg ? ( { } const res = await axios.get (`${ API_BASE_URL }/tags/autocomplete`, { params: { q } }) - const data = res.data as Tag[] - setSuggestions (data) + const data = toCamel (res.data, { deep: true }) as Tag[] + setSuggestions (data.filter (t => t.postCount > 0)) if (suggestions.length > 0) setSuggestionsVsbl (true) } diff --git a/frontend/src/components/TagSearchBox.tsx b/frontend/src/components/TagSearchBox.tsx index 79c912f..cb62541 100644 --- a/frontend/src/components/TagSearchBox.tsx +++ b/frontend/src/components/TagSearchBox.tsx @@ -1,3 +1,4 @@ +import TagLink from '@/components/TagLink' import { cn } from '@/lib/utils' import type { FC } from 'react' @@ -22,8 +23,7 @@ export default (({ suggestions, activeIndex, onSelect }: Props) => { className={cn ('px-3 py-2 cursor-pointer hover:bg-gray-300 dark:hover:bg-gray-700', i === activeIndex && 'bg-gray-300 dark:bg-gray-700')} onMouseDown={() => onSelect (tag)}> - {tag.name} - {{tag.postCount}} + ))} ) }) satisfies FC diff --git a/frontend/src/types.ts b/frontend/src/types.ts index a2f57b7..5cf9f5d 100644 --- a/frontend/src/types.ts +++ b/frontend/src/types.ts @@ -44,12 +44,13 @@ export type SubMenuItem = visible?: boolean } export type Tag = { - id: number - name: string - category: Category - postCount: number - hasWiki: boolean - children?: Tag[] } + id: number + name: string + category: Category + postCount: number + hasWiki: boolean + children?: Tag[] + matchedAlias?: string | null } export type User = { id: number