feat: some shit
This commit is contained in:
@ -3,7 +3,7 @@ import { useEffect, useRef } from "preact/hooks";
|
||||
export function useEventListener<T extends Event>(
|
||||
eventName: string,
|
||||
handler: (event: T) => void,
|
||||
element = window,
|
||||
element: Window | HTMLElement = window,
|
||||
) {
|
||||
console.log("Add Eventlistener", { eventName, element, handler });
|
||||
// Create a ref that stores handler
|
||||
|
@ -27,8 +27,8 @@ export interface GiteaOauthUser {
|
||||
groups: any;
|
||||
}
|
||||
|
||||
export type SearchResult = SearchResponse<{
|
||||
id:string;
|
||||
export type TypesenseDocument = {
|
||||
id: string;
|
||||
name: string;
|
||||
type: keyof typeof resources;
|
||||
date?: string;
|
||||
@ -36,4 +36,6 @@ export type SearchResult = SearchResponse<{
|
||||
tags: string[];
|
||||
description?: string;
|
||||
image?: string;
|
||||
}>;
|
||||
};
|
||||
|
||||
export type SearchResult = SearchResponse<TypesenseDocument>;
|
||||
|
@ -6,6 +6,7 @@ import { getAllArticles } from "@lib/resource/articles.ts";
|
||||
import { createLogger } from "@lib/log.ts";
|
||||
import { debounce } from "https://deno.land/std@0.193.0/async/mod.ts";
|
||||
import { getAllSeries } from "@lib/resource/series.ts";
|
||||
import { TypesenseDocument } from "@lib/types.ts";
|
||||
|
||||
const log = createLogger("typesense");
|
||||
|
||||
@ -94,6 +95,16 @@ async function initializeTypesense() {
|
||||
|
||||
const init = initializeTypesense();
|
||||
|
||||
export async function createTypesenseDocument(doc: TypesenseDocument) {
|
||||
const client = await getTypeSenseClient();
|
||||
if (!client) return;
|
||||
|
||||
await client.collections("resources").documents().create(
|
||||
doc,
|
||||
{ action: "upsert" },
|
||||
);
|
||||
}
|
||||
|
||||
async function synchronizeWithTypesense() {
|
||||
await init;
|
||||
try {
|
||||
|
Reference in New Issue
Block a user