mirror of
https://github.com/lucide-icons/lucide.git
synced 2026-11-13 13:48:26 +00:00
* setup icon popularity call * Adjust sort button * Adjust sorting * Adds aliases * Format code * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Add check for env variable * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> * Improve styling on mobile * Remove hardcoded sort icon * Fix build * Format code --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
30 lines
581 B
TypeScript
30 lines
581 B
TypeScript
import Fuse from 'fuse.js';
|
|
import { shallowRef, computed, Ref } from 'vue';
|
|
|
|
const useSearch = <T>(
|
|
query: Ref<string>,
|
|
collection: Ref<T[]>,
|
|
keys: Fuse.FuseOptionKeyObject<T>[] = [],
|
|
) => {
|
|
const index = shallowRef(
|
|
new Fuse(collection.value, {
|
|
threshold: 0.2,
|
|
keys,
|
|
}),
|
|
);
|
|
|
|
const results = computed(() => {
|
|
index.value.setCollection(collection.value);
|
|
|
|
if (query.value) {
|
|
return index.value.search(query.value).map((result) => result.item);
|
|
}
|
|
|
|
return collection.value;
|
|
});
|
|
|
|
return results;
|
|
};
|
|
|
|
export default useSearch;
|