feat: 別名タグをサジェストに展開(#28) #244

マージ済み
みてるぞ が 2 個のコミットを feature/028 から main へマージ 2026-01-29 07:32:14 +09:00
4個のファイルの変更18行の追加9行の削除
コミット 9a4fef21a6 の変更だけを表示してゐます - すべてのコミットを表示
+7
ファイルの表示
@@ -91,6 +91,13 @@ export default (({ tag,
style={{ paddingLeft: `${ (nestLevel - 1) }rem` }}> style={{ paddingLeft: `${ (nestLevel - 1) }rem` }}>
</span>)} </span>)}
{tag.matchedAlias != null && (
<>
<span className={spanClass} {...props}>
{tag.matchedAlias}
</span>
<> </>
</>)}
{linkFlg {linkFlg
? ( ? (
<Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`} <Link to={`/posts?${ (new URLSearchParams ({ tags: tag.name })).toString () }`}
+2 -1
ファイルの表示
@@ -1,4 +1,5 @@
import axios from 'axios' import axios from 'axios'
import toCamel from 'camelcase-keys'
import React, { useEffect, useState } from 'react' import React, { useEffect, useState } from 'react'
import { useNavigate, useLocation } from 'react-router-dom' import { useNavigate, useLocation } from 'react-router-dom'
@@ -31,7 +32,7 @@ export default (() => {
} }
const res = await axios.get (`${ API_BASE_URL }/tags/autocomplete`, { params: { q } }) const res = await axios.get (`${ API_BASE_URL }/tags/autocomplete`, { params: { q } })
const data = res.data as Tag[] const data = toCamel (res.data, { deep: true }) as Tag[]
setSuggestions (data) setSuggestions (data)
if (suggestions.length > 0) if (suggestions.length > 0)
setSuggestionsVsbl (true) setSuggestionsVsbl (true)
+2 -2
ファイルの表示
@@ -1,3 +1,4 @@
import TagLink from '@/components/TagLink'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import type { FC } from 'react' 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', 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')} i === activeIndex && 'bg-gray-300 dark:bg-gray-700')}
onMouseDown={() => onSelect (tag)}> onMouseDown={() => onSelect (tag)}>
{tag.name} <TagLink tag={tag} linkFlg={false} withWiki={false}/>
{<span className="ml-2 text-sm text-gray-400">{tag.postCount}</span>}
</li>))} </li>))}
</ul>) </ul>)
}) satisfies FC<Props> }) satisfies FC<Props>
+2 -1
ファイルの表示
@@ -49,7 +49,8 @@ export type Tag = {
category: Category category: Category
postCount: number postCount: number
hasWiki: boolean hasWiki: boolean
children?: Tag[] } children?: Tag[]
matchedAlias?: string | null }
export type User = { export type User = {
id: number id: number