Fix Discover URL filter parsing, improve search sidebar (#5104)

* fix category parsing on discover

* Make categories (loader, platform, etc) colored in discover, also add i18n

* fix formatting

* add localized strings

---------

Co-authored-by: Creeperkatze <178587183+Creeperkatze@users.noreply.github.com>
Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
Creeperkatze
2026-01-16 00:01:09 +01:00
committed by GitHub
parent 169224560b
commit b0ed808745
4 changed files with 108 additions and 23 deletions

View File

@@ -558,32 +558,45 @@ export function useSearch(
})
for (const key of Object.keys(route.query).filter((key) => !readParams.has(key))) {
const type = filters.value.find((type) => type.query_param === key)
if (type) {
const values = getParamValuesAsArray(route.query[key])
const types = filters.value.filter((type) => type.query_param === key)
if (types.length === 0) {
console.error(`Unknown filter type: ${key}`)
continue
}
for (const value of values) {
const negative = !value.includes(':') && value.includes('!=')
const values = getParamValuesAsArray(route.query[key])
for (const value of values) {
const negative = !value.includes(':') && value.includes('!=')
let matched = false
for (const type of types) {
const option = type.options.find((option) => getOptionValue(option, negative) === value)
if (!option) {
continue
}
if (!option && type.allows_custom_options) {
currentFilters.value.push({
type: type.id,
option: option.id,
negative: negative,
})
matched = true
break
}
if (!matched) {
const customType = types.find((type) => type.allows_custom_options)
if (customType) {
currentFilters.value.push({
type: type.id,
type: customType.id,
option: value.replace('!=', ':'),
negative: negative,
})
} else if (option) {
currentFilters.value.push({
type: type.id,
option: option.id,
negative: negative,
})
} else {
console.error(`Unknown filter option: ${value}`)
console.error(`Unknown filter option for ${key}: ${value}`)
}
}
} else {
console.error(`Unknown filter type: ${key}`)
}
}
}