このコミットが含まれているのは:
@@ -13,7 +13,6 @@ import type { FormEvent, FC } from 'react'
|
||||
|
||||
import type { HelpSearchEntry } from '@/lib/help'
|
||||
|
||||
|
||||
type SearchConditions = { title: string; text: string }
|
||||
|
||||
|
||||
@@ -28,19 +27,23 @@ const HelpSearchPage: FC = () => {
|
||||
useEffect (() => {
|
||||
let active = true
|
||||
|
||||
void getHelpSearchEntries ('ja')
|
||||
.then (data => {
|
||||
void (async () => {
|
||||
try
|
||||
{
|
||||
if (active)
|
||||
setEntries (data)
|
||||
})
|
||||
.catch (err => {
|
||||
setEntries (await getHelpSearchEntries ('ja'))
|
||||
}
|
||||
catch (err)
|
||||
{
|
||||
if (active)
|
||||
setError (err instanceof Error ? err.message : '取得に失敗しました.')
|
||||
})
|
||||
.finally (() => {
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (active)
|
||||
setLoading (false)
|
||||
})
|
||||
}
|
||||
}) ()
|
||||
|
||||
return () => { active = false }
|
||||
}, [])
|
||||
@@ -49,10 +52,13 @@ const HelpSearchPage: FC = () => {
|
||||
const titleQuery = conditions.title.trim ().normalize ('NFKC').toLowerCase ()
|
||||
const textQuery = conditions.text.trim ().normalize ('NFKC').toLowerCase ()
|
||||
|
||||
return entries.filter (entry => (
|
||||
(!(titleQuery) || entry.title.normalize ('NFKC').toLowerCase ().includes (titleQuery))
|
||||
&& (!(textQuery) || entry.body.normalize ('NFKC').toLowerCase ().includes (textQuery))))
|
||||
.sort ((a, b) => a.title.localeCompare (b.title, 'ja'))
|
||||
return (
|
||||
entries.filter (entry => (
|
||||
(!(titleQuery)
|
||||
|| entry.title.normalize ('NFKC').toLowerCase ().includes (titleQuery))
|
||||
&& (!(textQuery)
|
||||
|| entry.body.normalize ('NFKC').toLowerCase ().includes (textQuery))))
|
||||
.sort ((a, b) => a.title.localeCompare (b.title, 'ja')))
|
||||
}, [entries, conditions])
|
||||
|
||||
const handleSearch = (ev: FormEvent<HTMLFormElement>) => {
|
||||
@@ -63,7 +69,7 @@ const HelpSearchPage: FC = () => {
|
||||
return (
|
||||
<MainArea>
|
||||
<Helmet>
|
||||
<title>{`ヘルプ | ${SITE_TITLE}`}</title>
|
||||
<title>{`ヘルプ | ${ SITE_TITLE }`}</title>
|
||||
</Helmet>
|
||||
|
||||
<div className="max-w-xl">
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする