mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-24 15:47:08 +00:00
Put tags and search of changelogs and versions in URL
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
import { useMemo, useState } from 'preact/hooks'
|
||||
import { Checkbox, TextInput } from '..'
|
||||
import { useLocale } from '../../contexts'
|
||||
import { useSearchParam } from '../../hooks'
|
||||
import type { VersionMeta } from '../../services'
|
||||
import { VersionEntry } from './VersionEntry'
|
||||
|
||||
const SEARCH_KEY = 'search'
|
||||
|
||||
interface Props {
|
||||
versions: VersionMeta[]
|
||||
link?: (id: string) => string
|
||||
@@ -12,11 +15,11 @@ export function VersionList({ versions, link }: Props) {
|
||||
const { locale } = useLocale()
|
||||
|
||||
const [snapshots, setSnapshots] = useState(true)
|
||||
const [search, setSearch] = useState('')
|
||||
const [search, setSearch] = useSearchParam(SEARCH_KEY)
|
||||
|
||||
const filteredVersions = useMemo(() => versions.filter(v => {
|
||||
if (v.type === 'snapshot' && !snapshots) return false
|
||||
return v.id.includes(search)
|
||||
return v.id.includes(search ?? '')
|
||||
}), [versions, snapshots, search])
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user