diff options
| author | Dhravya Shah <[email protected]> | 2024-06-18 17:58:46 -0500 |
|---|---|---|
| committer | Dhravya Shah <[email protected]> | 2024-06-18 17:58:46 -0500 |
| commit | f4bb71e8f7e07bb2e919b7f222d5acb2905eb8f2 (patch) | |
| tree | 7310dc521ef3559055bbe71f50c3861be2fa0503 /apps/web/app/helpers/lib | |
| parent | darkmode by default - so that the colors don't f up on lightmode devices (diff) | |
| parent | Create Embeddings for Canvas (diff) | |
| download | supermemory-default-darkmode.tar.xz supermemory-default-darkmode.zip | |
Diffstat (limited to 'apps/web/app/helpers/lib')
| -rw-r--r-- | apps/web/app/helpers/lib/get-metadata.ts | 40 | ||||
| -rw-r--r-- | apps/web/app/helpers/lib/get-theme-button.tsx | 11 | ||||
| -rw-r--r-- | apps/web/app/helpers/lib/handle-errors.ts | 25 | ||||
| -rw-r--r-- | apps/web/app/helpers/lib/searchParams.ts | 26 |
4 files changed, 0 insertions, 102 deletions
diff --git a/apps/web/app/helpers/lib/get-metadata.ts b/apps/web/app/helpers/lib/get-metadata.ts deleted file mode 100644 index 4609e49b..00000000 --- a/apps/web/app/helpers/lib/get-metadata.ts +++ /dev/null @@ -1,40 +0,0 @@ -"use server"; -import * as cheerio from "cheerio"; - -// TODO: THIS SHOULD PROBABLY ALSO FETCH THE OG-IMAGE -export async function getMetaData(url: string) { - const response = await fetch(url); - const html = await response.text(); - - const $ = cheerio.load(html); - - // Extract the base URL - const baseUrl = new URL(url).origin; - - // Extract title - const title = $("title").text().trim(); - - const description = $("meta[name=description]").attr("content") ?? ""; - - const _favicon = - $("link[rel=icon]").attr("href") ?? "https://supermemory.dhr.wtf/web.svg"; - - let favicon = - _favicon.trim().length > 0 - ? _favicon.trim() - : "https://supermemory.dhr.wtf/web.svg"; - if (favicon.startsWith("/")) { - favicon = baseUrl + favicon; - } else if (favicon.startsWith("./")) { - favicon = baseUrl + favicon.slice(1); - } - - // Prepare the metadata object - const metadata = { - title, - description, - image: favicon, - baseUrl, - }; - return metadata; -} diff --git a/apps/web/app/helpers/lib/get-theme-button.tsx b/apps/web/app/helpers/lib/get-theme-button.tsx deleted file mode 100644 index 020cc976..00000000 --- a/apps/web/app/helpers/lib/get-theme-button.tsx +++ /dev/null @@ -1,11 +0,0 @@ -// Theming that works perfectly with app router (no flicker, jumps etc!) - -import dynamic from "next/dynamic"; - -// Don't SSR the toggle since the value on the server will be different than the client -export const getThemeToggler = () => - dynamic(() => import("@repo/ui/shadcn/theme-toggle"), { - ssr: false, - // Make sure to code a placeholder so the UI doesn't jump when the component loads - loading: () => <div className="w-6 h-6" />, - }); diff --git a/apps/web/app/helpers/lib/handle-errors.ts b/apps/web/app/helpers/lib/handle-errors.ts deleted file mode 100644 index 42cae589..00000000 --- a/apps/web/app/helpers/lib/handle-errors.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { isRedirectError } from "next/dist/client/components/redirect"; -import { toast } from "sonner"; -import { z } from "zod"; - -export function getErrorMessage(err: unknown) { - const unknownError = "Something went wrong, please try again later."; - - if (err instanceof z.ZodError) { - const errors = err.issues.map((issue) => { - return issue.message; - }); - return errors.join("\n"); - } else if (err instanceof Error) { - return err.message; - } else if (isRedirectError(err)) { - throw err; - } else { - return unknownError; - } -} - -export function showErrorToast(err: unknown) { - const errorMessage = getErrorMessage(err); - return toast.error(errorMessage); -} diff --git a/apps/web/app/helpers/lib/searchParams.ts b/apps/web/app/helpers/lib/searchParams.ts deleted file mode 100644 index 9899eaf7..00000000 --- a/apps/web/app/helpers/lib/searchParams.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { - createSearchParamsCache, - parseAsInteger, - parseAsString, - parseAsBoolean, - parseAsArrayOf, - parseAsJson, -} from "nuqs/server"; -import { z } from "zod"; - -export const homeSearchParamsCache = createSearchParamsCache({ - firstTime: parseAsBoolean.withDefault(false), -}); - -export const chatSearchParamsCache = createSearchParamsCache({ - firstTime: parseAsBoolean.withDefault(false), - q: parseAsString.withDefault(""), - spaces: parseAsArrayOf( - parseAsJson(() => - z.object({ - id: z.string(), - name: z.string(), - }), - ), - ).withDefault([]), -}); |