remove dep
This commit is contained in:
17
superpage/package-lock.json
generated
17
superpage/package-lock.json
generated
@@ -23,8 +23,6 @@
|
|||||||
"astro-icon": "^1.1.5",
|
"astro-icon": "^1.1.5",
|
||||||
"astro-pagefind": "^1.8.3",
|
"astro-pagefind": "^1.8.3",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"fuse.js": "^7.1.0",
|
|
||||||
"meilisearch": "^0.50.0",
|
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-hook-form": "^7.56.0",
|
"react-hook-form": "^7.56.0",
|
||||||
@@ -3952,15 +3950,6 @@
|
|||||||
"url": "https://github.com/sponsors/ljharb"
|
"url": "https://github.com/sponsors/ljharb"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/fuse.js": {
|
|
||||||
"version": "7.1.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/fuse.js/-/fuse.js-7.1.0.tgz",
|
|
||||||
"integrity": "sha512-trLf4SzuuUxfusZADLINj+dE8clK1frKdmqiJNb1Es75fmI5oY6X2mxLVUciLLjxqw/xr72Dhy+lER6dGd02FQ==",
|
|
||||||
"license": "Apache-2.0",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=10"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/gensync": {
|
"node_modules/gensync": {
|
||||||
"version": "1.0.0-beta.2",
|
"version": "1.0.0-beta.2",
|
||||||
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.2.tgz",
|
||||||
@@ -5248,12 +5237,6 @@
|
|||||||
"integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==",
|
"integrity": "sha512-IEn+pegP1aManZuckezWCO+XZQDplx1366JoVhTpMpBB1sPey/SbveZQUosKiKiGYjg1wH4pMlNgXbCiYgihQA==",
|
||||||
"license": "CC0-1.0"
|
"license": "CC0-1.0"
|
||||||
},
|
},
|
||||||
"node_modules/meilisearch": {
|
|
||||||
"version": "0.50.0",
|
|
||||||
"resolved": "https://registry.npmjs.org/meilisearch/-/meilisearch-0.50.0.tgz",
|
|
||||||
"integrity": "sha512-9IzIkobvnuS18Eg4dq/eJB9W+eXqeLZjNRgq/kKMswSmVYYSQsXqGgSuCA0JkF+o5RwJlwIsieQee6rh313VhA==",
|
|
||||||
"license": "MIT"
|
|
||||||
},
|
|
||||||
"node_modules/micromark": {
|
"node_modules/micromark": {
|
||||||
"version": "4.0.2",
|
"version": "4.0.2",
|
||||||
"resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz",
|
"resolved": "https://registry.npmjs.org/micromark/-/micromark-4.0.2.tgz",
|
||||||
|
|||||||
@@ -24,8 +24,6 @@
|
|||||||
"astro-icon": "^1.1.5",
|
"astro-icon": "^1.1.5",
|
||||||
"astro-pagefind": "^1.8.3",
|
"astro-pagefind": "^1.8.3",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
"fuse.js": "^7.1.0",
|
|
||||||
"meilisearch": "^0.50.0",
|
|
||||||
"react": "^19.1.0",
|
"react": "^19.1.0",
|
||||||
"react-dom": "^19.1.0",
|
"react-dom": "^19.1.0",
|
||||||
"react-hook-form": "^7.56.0",
|
"react-hook-form": "^7.56.0",
|
||||||
|
|||||||
@@ -1,62 +0,0 @@
|
|||||||
import { useState } from "react";
|
|
||||||
import Fuse from "fuse.js";
|
|
||||||
|
|
||||||
// https://fusejs.io/api/options.html
|
|
||||||
const options = {
|
|
||||||
keys: ["data.title", "data.slug"],
|
|
||||||
includeMatches: true,
|
|
||||||
minMatchCharLength: 2,
|
|
||||||
threshold: 0.5,
|
|
||||||
};
|
|
||||||
|
|
||||||
export default function Search({ searchlist }) {
|
|
||||||
const [query, setQuery] = useState("");
|
|
||||||
|
|
||||||
const fuse = new Fuse(searchlist, options);
|
|
||||||
// Set a limit to the items: 5
|
|
||||||
const items = fuse
|
|
||||||
.search(query)
|
|
||||||
.map((result) => result.item)
|
|
||||||
.slice(0, 5);
|
|
||||||
|
|
||||||
const onChange = (e) => {
|
|
||||||
setQuery(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
|
||||||
<>
|
|
||||||
<input
|
|
||||||
id="search"
|
|
||||||
type="text"
|
|
||||||
className="focus:outline-none w-full pr-5 py-3.5 rounded-r-xl"
|
|
||||||
value={query}
|
|
||||||
autoComplete="false"
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{query.length > 1 && (
|
|
||||||
<div className="absolute w-full top-full bg-white mt-1.5 p-5 rounded-xl drop-shadow space-y-2.5">
|
|
||||||
<p>
|
|
||||||
Encontrado {items.length} resultado(s) para '
|
|
||||||
<strong>{query}</strong>'
|
|
||||||
</p>
|
|
||||||
|
|
||||||
{items.length > 0 && (
|
|
||||||
<ul className="list-disc list-inside">
|
|
||||||
{items.map(({ data }, idx) => (
|
|
||||||
<li key={idx}>
|
|
||||||
<a
|
|
||||||
href={`/${data.slug}`}
|
|
||||||
className="font-medium hover:underline"
|
|
||||||
>
|
|
||||||
{data.title}
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
))}
|
|
||||||
</ul>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user