feat: Add solid-highlight-words package and use in Search
This commit is contained in:
parent
f42e2b5788
commit
e54b07dfd2
@ -20,6 +20,7 @@
|
|||||||
"remark-frontmatter": "^5.0.0",
|
"remark-frontmatter": "^5.0.0",
|
||||||
"remark-heading-id": "^1.0.1",
|
"remark-heading-id": "^1.0.1",
|
||||||
"solid-heroicons": "^3.2.4",
|
"solid-heroicons": "^3.2.4",
|
||||||
|
"solid-highlight-words": "^1.0.4",
|
||||||
"solid-js": "^1.9.5",
|
"solid-js": "^1.9.5",
|
||||||
"solid-jsx": "^1.1.4",
|
"solid-jsx": "^1.1.4",
|
||||||
"solid-mdx": "^0.0.7",
|
"solid-mdx": "^0.0.7",
|
||||||
@ -990,6 +991,8 @@
|
|||||||
|
|
||||||
"solid-heroicons": ["solid-heroicons@3.2.4", "", { "dependencies": { "solid-js": "^1.7.6" } }, "sha512-u6BMdFLvkJnvUGYzdFcWp1wvJ4hb9Y1zd3AbZ9D3bUmmiy9jBzNZX+RcqBCI2EKRvdQwAb1UB9bkESfqfhayDg=="],
|
"solid-heroicons": ["solid-heroicons@3.2.4", "", { "dependencies": { "solid-js": "^1.7.6" } }, "sha512-u6BMdFLvkJnvUGYzdFcWp1wvJ4hb9Y1zd3AbZ9D3bUmmiy9jBzNZX+RcqBCI2EKRvdQwAb1UB9bkESfqfhayDg=="],
|
||||||
|
|
||||||
|
"solid-highlight-words": ["solid-highlight-words@1.0.4", "", { "peerDependencies": { "solid-js": "^1.8.0" } }, "sha512-Qxnc9W69HsGUl16wrpNwW3j3IvJaFVQjJM+BFfwU3WReSpPCzHSk7vUHzb9V1V3vh0azq1T73+OqtICmnSQ8CQ=="],
|
||||||
|
|
||||||
"solid-js": ["solid-js@1.9.5", "", { "dependencies": { "csstype": "^3.1.0", "seroval": "^1.1.0", "seroval-plugins": "^1.1.0" } }, "sha512-ogI3DaFcyn6UhYhrgcyRAMbu/buBJitYQASZz5WzfQVPP10RD2AbCoRZ517psnezrasyCbWzIxZ6kVqet768xw=="],
|
"solid-js": ["solid-js@1.9.5", "", { "dependencies": { "csstype": "^3.1.0", "seroval": "^1.1.0", "seroval-plugins": "^1.1.0" } }, "sha512-ogI3DaFcyn6UhYhrgcyRAMbu/buBJitYQASZz5WzfQVPP10RD2AbCoRZ517psnezrasyCbWzIxZ6kVqet768xw=="],
|
||||||
|
|
||||||
"solid-jsx": ["solid-jsx@1.1.4", "", { "peerDependencies": { "solid-js": ">=1.4.0" } }, "sha512-A4E9cB+wZpHZrXzv3+OWr6zaGS0FjD/UAKqbI38R1JwogjlBXdSGC2PgaIMisnGYKL3oJ55FPLv4QRkENmdbWQ=="],
|
"solid-jsx": ["solid-jsx@1.1.4", "", { "peerDependencies": { "solid-js": ">=1.4.0" } }, "sha512-A4E9cB+wZpHZrXzv3+OWr6zaGS0FjD/UAKqbI38R1JwogjlBXdSGC2PgaIMisnGYKL3oJ55FPLv4QRkENmdbWQ=="],
|
||||||
|
|||||||
@ -19,7 +19,7 @@ import {
|
|||||||
} from "solid-js";
|
} from "solid-js";
|
||||||
import { Dialog, DialogPanel } from "terracotta";
|
import { Dialog, DialogPanel } from "terracotta";
|
||||||
import { useDebounce } from "@/hooks/useDebounce";
|
import { useDebounce } from "@/hooks/useDebounce";
|
||||||
// import Highlighter from "react-highlight-words";
|
import { Highlighter } from "solid-highlight-words";
|
||||||
// import { navigation } from "@/lib/navigation";
|
// import { navigation } from "@/lib/navigation";
|
||||||
import { navigate } from "vike/client/router";
|
import { navigate } from "vike/client/router";
|
||||||
import { onSearch } from "./Search.telefunc";
|
import { onSearch } from "./Search.telefunc";
|
||||||
@ -123,16 +123,14 @@ function SearchInput() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function HighlightQuery({ text, query }: { text: string; query: string }) {
|
function HighlightQuery({ text, query }: { text: string; query: string }) {
|
||||||
return <span>{text}</span>;
|
return (
|
||||||
|
<Highlighter
|
||||||
// return (
|
highlightClass="group-aria-selected:underline bg-transparent text-violet-600"
|
||||||
// <Highlighter
|
searchWords={[query]}
|
||||||
// highlightclass="group-aria-selected:underline bg-transparent text-violet-600 dark:text-violet-400"
|
autoEscape={true}
|
||||||
// searchWords={[query]}
|
textToHighlight={text}
|
||||||
// autoEscape={true}
|
/>
|
||||||
// textToHighlight={text}
|
);
|
||||||
// />
|
|
||||||
// );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function SearchResultItem(props: { result: SearchResult; query: string }) {
|
function SearchResultItem(props: { result: SearchResult; query: string }) {
|
||||||
|
|||||||
@ -25,6 +25,7 @@
|
|||||||
"remark-frontmatter": "^5.0.0",
|
"remark-frontmatter": "^5.0.0",
|
||||||
"remark-heading-id": "^1.0.1",
|
"remark-heading-id": "^1.0.1",
|
||||||
"solid-heroicons": "^3.2.4",
|
"solid-heroicons": "^3.2.4",
|
||||||
|
"solid-highlight-words": "^1.0.4",
|
||||||
"solid-js": "^1.9.5",
|
"solid-js": "^1.9.5",
|
||||||
"solid-jsx": "^1.1.4",
|
"solid-jsx": "^1.1.4",
|
||||||
"solid-mdx": "^0.0.7",
|
"solid-mdx": "^0.0.7",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user