minor changes and improvements

This commit is contained in:
Dhravya 2024-06-11 19:14:37 -05:00
parent a341908564
commit 5ab5d8f12f
6 changed files with 104 additions and 104 deletions

View file

@ -11,11 +11,7 @@ async function Signin() {
<div className="flex items-center justify-between min-h-screen">
<div className="relative w-full lg:w-1/2 flex items-center justify-center lg:justify-start min-h-screen bg-secondary p-8">
<div className="absolute top-0 left-0 p-8 text-white inline-flex gap-2 items-center">
<Image
src={Logo}
alt="SuperMemory logo"
className="brightness-100"
/>
<Image src={Logo} alt="SuperMemory logo" className="brightness-100" />
<span className="text-xl">SuperMemory.ai</span>
</div>
@ -28,7 +24,7 @@ async function Signin() {
</p>
<div className="flex items-center gap-4">
<div
className="w-3/4"
className={`transition-width z-20 rounded-2xl bg-gradient-to-br from-gray-200/70 to-transparent p-[0.7px] duration-300 ease-in-out w-3/4 hover:bg-opacity-90 hover:shadow-lg group`}
>
<form
action={async () => {
@ -40,12 +36,10 @@ async function Signin() {
>
<button
type="submit"
className={`text-white flex gap-3 justify-center bg-tranparent hover:border-transparent hover:bg-[#37485E] border-[#37485E] border-2 w-full py-3 items-center rounded-lg duration-100 hover:rounded-3xl`}
className={`relative text-white transition-width flex justify-between w-full items-center rounded-2xl bg-[#37485E] px-6 py-4 outline-none duration-300 focus:outline-none group-hover:bg-opacity-50 group`}
>
<div className="-translate-y-[1px]">
<Google />
</div>
<span className="text-xl font-medium tracking-wide relative ">
<Google />
<span className="relative w-full self-start">
Continue with Google
</span>
</button>
@ -55,7 +49,8 @@ async function Signin() {
<div className="text-slate-100 absolute bottom-4 lg:left-8 lg:-translate-x-0 left-1/2 -translate-x-1/2 ">
<Link href="/terms" className="text-slate-300">
Terms of Service
</Link> |
</Link>{" "}
|
<Link href="/privacy" className="text-slate-300">
{" "}
Privacy Policy

View file

@ -1,73 +1,94 @@
import { AssetRecordType, TLAsset, getHashForString, truncateStringWithEllipsis } from 'tldraw'
import {
AssetRecordType,
TLAsset,
getHashForString,
truncateStringWithEllipsis,
} from "tldraw";
// import { BOOKMARK_ENDPOINT } from './config'
interface ResponseBody {
title?: string
description?: string
image?: string
title?: string;
description?: string;
image?: string;
}
export async function createAssetFromUrl({ url }: { type: 'url'; url: string }): Promise<TLAsset> {
// try {
// // First, try to get the meta data from our endpoint
// const meta = (await (
// await fetch(BOOKMARK_ENDPOINT, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// url,
// }),
// })
// ).json()) as ResponseBody
export async function createAssetFromUrl({
url,
}: {
type: "url";
url: string;
}): Promise<TLAsset> {
// try {
// // First, try to get the meta data from our endpoint
// const meta = (await (
// await fetch(BOOKMARK_ENDPOINT, {
// method: 'POST',
// headers: {
// 'Content-Type': 'application/json',
// },
// body: JSON.stringify({
// url,
// }),
// })
// ).json()) as ResponseBody
// return {
// id: AssetRecordType.createId(getHashForString(url)),
// typeName: 'asset',
// type: 'bookmark',
// props: {
// src: url,
// description: meta.description ?? '',
// image: meta.image ?? '',
// title: meta.title ?? truncateStringWithEllipsis(url, 32),
// },
// meta: {},
// }
// } catch (error) {
// Otherwise, fallback to fetching data from the url
// return {
// id: AssetRecordType.createId(getHashForString(url)),
// typeName: 'asset',
// type: 'bookmark',
// props: {
// src: url,
// description: meta.description ?? '',
// image: meta.image ?? '',
// title: meta.title ?? truncateStringWithEllipsis(url, 32),
// },
// meta: {},
// }
// } catch (error) {
// Otherwise, fallback to fetching data from the url
let meta: { image: string; title: string; description: string }
let meta: { image: string; title: string; description: string };
try {
const resp = await fetch(url, { method: 'GET', mode: 'no-cors' })
const html = await resp.text()
const doc = new DOMParser().parseFromString(html, 'text/html')
meta = {
image: doc.head.querySelector('meta[property="og:image"]')?.getAttribute('content') ?? '',
title:
doc.head.querySelector('meta[property="og:title"]')?.getAttribute('content') ??
truncateStringWithEllipsis(url, 32),
description:
doc.head.querySelector('meta[property="og:description"]')?.getAttribute('content') ?? '',
}
} catch (error) {
console.error(error)
meta = { image: '', title: truncateStringWithEllipsis(url, 32), description: '' }
}
try {
const resp = await fetch(url, { method: "GET", mode: "no-cors" });
const html = await resp.text();
const doc = new DOMParser().parseFromString(html, "text/html");
meta = {
image:
doc.head
.querySelector('meta[property="og:image"]')
?.getAttribute("content") ?? "",
title:
doc.head
.querySelector('meta[property="og:title"]')
?.getAttribute("content") ?? truncateStringWithEllipsis(url, 32),
description:
doc.head
.querySelector('meta[property="og:description"]')
?.getAttribute("content") ?? "",
};
} catch (error) {
console.error(error);
meta = {
image: "",
title: truncateStringWithEllipsis(url, 32),
description: "",
};
}
// Create the bookmark asset from the meta
return {
id: AssetRecordType.createId(getHashForString(url)),
typeName: 'asset',
type: 'bookmark',
props: {
src: url,
image: meta.image,
title: meta.title,
description: meta.description,
},
meta: {},
}
// }
}
// Create the bookmark asset from the meta
return {
id: AssetRecordType.createId(getHashForString(url)),
typeName: "asset",
type: "bookmark",
props: {
src: url,
image: meta.image,
title: meta.title,
description: meta.description,
favicon: meta.image,
},
meta: {},
};
// }
}

View file

@ -68,6 +68,7 @@ function DynamicIslandContent() {
if (e.key === "Escape") {
setshow(true);
}
console.log(e.key, lastBtn.current);
if (e.key === "a" && lastBtn.current === "Alt") {
setshow(false);
}

View file

@ -1,29 +1,5 @@
"use client";
import {
AnimatePresence,
useMotionValueEvent,
@ -32,7 +8,13 @@ import {
} from "framer-motion";
import React, { useState } from "react";
function Topbar({charsCount, saveStatus}: {charsCount: number | undefined; saveStatus: string}) {
function Topbar({
charsCount,
saveStatus,
}: {
charsCount: number | undefined;
saveStatus: string;
}) {
const [visible, setVisible] = useState(true);
const { scrollYProgress } = useScroll();

View file

@ -10,7 +10,8 @@
"cf-typegen": "wrangler types --env-interface CloudflareEnv env.d.ts",
"pages:build": "bunx @cloudflare/next-on-pages",
"preview": "bun pages:build && wrangler pages dev",
"deploy": "bun pages:build && wrangler pages deploy"
"deploy": "bun pages:build && wrangler pages deploy",
"schema-update": "bunx drizzle-orm"
},
"dependencies": {
"@million/lint": "^1.0.0-rc.11",

View file

@ -12,8 +12,8 @@ bucket_name = "dev-r2-anycontext"
[[d1_databases]]
binding = "DATABASE"
database_name = "prod-d1-tutorial"
database_id = "325fe40a-bdfc-43ec-837b-021bbcc570e8"
database_name = "dev-d1-anycontext"
database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
# [[unsafe.bindings]]
# name = "RATELIMITER"