Rebuild the site on the stack the other converted sites share: Vite 8, React 19, TypeScript 7, react-router 8, Biome and sanitize.css, with the site data moved out of the bundle into static-contents/. - base the database and pico code on the other converted sites, keeping this site's layout, pages and item fields - read file timestamps as Unix seconds in the file and license views - serve all module data from modules/, redirecting the old download and /database/file URLs - keep form controls on white - track page views with GA4
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { useCallback } from 'react';
|
|
import { useLocation } from 'react-router';
|
|
import type { MultiLang } from '../config';
|
|
import Functions from '../functions';
|
|
import DatabaseListItem from './lib/DatabaseListItem';
|
|
import ItemUtil, { type SearchCallbackFunc, type SortCondition } from './lib/ItemUtil';
|
|
|
|
interface Props {
|
|
lang: MultiLang;
|
|
}
|
|
|
|
const DatabaseSearchByKeyword = (props: Props) => {
|
|
const { lang } = props;
|
|
const location = useLocation();
|
|
const { type, keyword } = ItemUtil.getSearchKeywordByQuery(location.search);
|
|
|
|
const searchFunc = useCallback(
|
|
(condition: SortCondition, func: SearchCallbackFunc) => {
|
|
if (keyword === '') {
|
|
func({ total: 0, data: [] });
|
|
} else {
|
|
ItemUtil.getListByKeyword(type, keyword, condition, func);
|
|
}
|
|
},
|
|
[type, keyword]
|
|
);
|
|
|
|
return (
|
|
<div className="list">
|
|
<h3>{Functions.mlang('[en]Listing item[/en][ja]アイテム一覧[/ja]', lang)}</h3>
|
|
<p>
|
|
{Functions.mlang('[en]Search Keyword[/en][ja]検索キーワード[/ja]', lang)} : {keyword}
|
|
</p>
|
|
<DatabaseListItem lang={lang} url={ItemUtil.getSearchByKeywordUrl(type, keyword)} search={searchFunc} />
|
|
</div>
|
|
);
|
|
};
|
|
|
|
export default DatabaseSearchByKeyword;
|