feat: refs #6839 normalize search #936
|
@ -34,18 +34,26 @@ const search = ref(null);
|
|||
|
||||
const filteredItems = computed(() => {
|
||||
if (!search.value) return items.value;
|
||||
const normalizedSearch = normalize(search.value);
|
||||
return items.value.filter((item) => {
|
||||
const locale = t(item.title).toLowerCase();
|
||||
return locale.includes(search.value.toLowerCase());
|
||||
const locale = normalize(t(item.title));
|
||||
return locale.includes(normalizedSearch);
|
||||
});
|
||||
});
|
||||
|
||||
const filteredPinnedModules = computed(() => {
|
||||
if (!search.value) return pinnedModules.value;
|
||||
const normalizedSearch = search.value
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase();
|
||||
const map = new Map();
|
||||
for (const [key, pinnedModule] of pinnedModules.value) {
|
||||
const locale = t(pinnedModule.title).toLowerCase();
|
||||
if (locale.includes(search.value.toLowerCase())) map.set(key, pinnedModule);
|
||||
const locale = t(pinnedModule.title)
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase();
|
||||
if (locale.includes(normalizedSearch)) map.set(key, pinnedModule);
|
||||
}
|
||||
return map;
|
||||
});
|
||||
|
@ -147,6 +155,13 @@ async function togglePinned(item, event) {
|
|||
const handleItemExpansion = (itemName) => {
|
||||
expansionItemElements[itemName].scrollToLastElement();
|
||||
};
|
||||
|
||||
function normalize(text) {
|
||||
|
||||
return text
|
||||
.normalize('NFD')
|
||||
.replace(/[\u0300-\u036f]/g, '')
|
||||
.toLowerCase();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
|
|
Loading…
Reference in New Issue
Pasa los acentos o diéresis a letras normales, solicitado por J. Gallego.