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