()
| 5 | |
| 6 | /** a search button that starts from the last segment of the missing url */ |
| 7 | export const NotFoundSearch = () => { |
| 8 | const [query, setQuery] = useState<string>() |
| 9 | |
| 10 | useEffect(() => { |
| 11 | const segment = location.pathname.split("/").filter(Boolean).at(-1) ?? "" |
| 12 | setQuery( |
| 13 | decodeURIComponent(segment) |
| 14 | .replace(/\.\w+$/, "") |
| 15 | .replace(/[_-]/g, " ") |
| 16 | ) |
| 17 | }, []) |
| 18 | |
| 19 | return <SearchButton query={query} /> |
| 20 | } |