fix: soo many lint errors
This commit is contained in:
@@ -10,7 +10,7 @@ import { Rating } from "@components/Rating.tsx";
|
||||
import { useSignal } from "@preact/signals";
|
||||
import Image from "@components/Image.tsx";
|
||||
import { Emoji } from "@components/Emoji.tsx";
|
||||
import { GenericResource } from "@lib/marka/schema.ts";
|
||||
import { GenericResource, getNameOfResource } from "@lib/marka/schema.ts";
|
||||
|
||||
export async function fetchQueryResource(url: URL, type = "") {
|
||||
const query = url.searchParams.get("q");
|
||||
@@ -33,21 +33,23 @@ export async function fetchQueryResource(url: URL, type = "") {
|
||||
}
|
||||
}
|
||||
|
||||
export const RedirectSearchHandler = () => {
|
||||
if (getCookie("session_cookie")) {
|
||||
useEventListener("keydown", (e: KeyboardEvent) => {
|
||||
if (e?.target?.nodeName == "INPUT") return;
|
||||
export function RedirectSearchHandler() {
|
||||
useEventListener("keydown", (e: KeyboardEvent) => {
|
||||
if (getCookie("session_cookie")) {
|
||||
const target = e.target as HTMLInputElement;
|
||||
if (target.nodeName == "INPUT") return;
|
||||
if (
|
||||
e.key === "?" &&
|
||||
globalThis.location.search === ""
|
||||
) {
|
||||
globalThis.location.href += "?q=";
|
||||
}
|
||||
}, IS_BROWSER ? document?.body : undefined);
|
||||
}
|
||||
}
|
||||
}, IS_BROWSER ? document?.body : undefined);
|
||||
|
||||
return;
|
||||
};
|
||||
// deno-lint-ignore jsx-no-useless-fragment
|
||||
return <></>;
|
||||
}
|
||||
|
||||
const SearchResultImage = ({ src }: { src: string }) => {
|
||||
return (
|
||||
@@ -67,7 +69,8 @@ export const SearchResultItem = (
|
||||
showEmoji?: boolean;
|
||||
},
|
||||
) => {
|
||||
const resourceType = resources[item?.content._type];
|
||||
const resourceType =
|
||||
resources[item.content._type.toLowerCase() as keyof typeof resources];
|
||||
const href = item?.path.replace("/resources", "").replace(/\.md$/, "");
|
||||
return (
|
||||
<a
|
||||
@@ -78,8 +81,7 @@ export const SearchResultItem = (
|
||||
? <Emoji class="w-7 h-7" name={resourceType.emoji} />
|
||||
: ""}
|
||||
{item.image && <SearchResultImage src={item.image?.url} />}
|
||||
{item.content?.headline || item.content?.name ||
|
||||
item.content?.itemReviewed.name || item?.name}
|
||||
{getNameOfResource(item)}
|
||||
</a>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user