mirror of
https://github.com/supermemoryai/supermemory.git
synced 2026-09-11 22:51:05 +00:00
makeshift notes page
This commit is contained in:
parent
9a5e879a62
commit
79e2673080
8 changed files with 57 additions and 7 deletions
|
|
@ -174,7 +174,7 @@ function LinkComponent({
|
|||
// TODO: DISPLAY THE ITEM BASED ON `type` being note or page
|
||||
return (
|
||||
<Link
|
||||
href={url}
|
||||
href={url.replace("https://beta.supermemory.ai", "")}
|
||||
className={`bg-secondary border-2 border-border rounded-xl ${type === "tweet" ? "" : "p-4"} hover:scale-105 transition duration-200`}
|
||||
>
|
||||
{type === "page" ? (
|
||||
|
|
|
|||
24
apps/web/app/(dash)/note/[noteid]/page.tsx
Normal file
24
apps/web/app/(dash)/note/[noteid]/page.tsx
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import { getNoteFromId } from "@/app/actions/fetchers";
|
||||
import { NotebookIcon } from "lucide-react";
|
||||
|
||||
async function Page({ params }: { params: { noteid: string } }) {
|
||||
const note = await getNoteFromId(params.noteid as string);
|
||||
|
||||
if (!note.success) {
|
||||
return <div>Failed to load note</div>;
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-w-3xl mt-16 md:mt-32 flex mx-auto w-full flex-col">
|
||||
<div className="flex items-center gap-2 text-xs">
|
||||
<NotebookIcon className="w-3 h-3" /> Note
|
||||
</div>
|
||||
<h1 className="text-white w-full font-medium text-2xl text-left mt-2">
|
||||
{note.data?.title}
|
||||
</h1>
|
||||
<div className="w-full pb-20 mt-12">{note.data?.content}</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default Page;
|
||||
|
|
@ -171,7 +171,7 @@ export const createMemory = async (input: {
|
|||
pageContent = input.content;
|
||||
noteId = new Date().getTime();
|
||||
metadata = {
|
||||
baseUrl: `https://beta.supermemory.ai/?note=${noteId}`,
|
||||
baseUrl: `https://beta.supermemory.ai/note/${noteId}`,
|
||||
description: `Note created at ${new Date().toLocaleString()}`,
|
||||
image: "https://supermemory.ai/logo.png",
|
||||
title: `${pageContent.slice(0, 20)} ${pageContent.length > 20 ? "..." : ""}`,
|
||||
|
|
|
|||
|
|
@ -200,3 +200,26 @@ export const getSessionAuthToken = async (): ServerActionReturnType<string> => {
|
|||
data: token,
|
||||
};
|
||||
};
|
||||
|
||||
export const getNoteFromId = async (
|
||||
noteId: string,
|
||||
): ServerActionReturnType<Content> => {
|
||||
const data = await auth();
|
||||
|
||||
if (!data || !data.user || !data.user.id) {
|
||||
redirect("/signin");
|
||||
return { error: "Not authenticated", success: false };
|
||||
}
|
||||
|
||||
const note = await db.query.storedContent.findFirst({
|
||||
where: and(
|
||||
eq(storedContent.noteId, parseInt(noteId)),
|
||||
eq(users, data.user.id),
|
||||
),
|
||||
});
|
||||
|
||||
return {
|
||||
success: true,
|
||||
data: note,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,6 +59,8 @@ const createMemoryFromAPI = async (input: {
|
|||
"#supermemory-user-" +
|
||||
input.userId;
|
||||
|
||||
const noteId = new Date().getTime();
|
||||
|
||||
// Insert into database
|
||||
try {
|
||||
const insertResponse = await db
|
||||
|
|
@ -73,6 +75,7 @@ const createMemoryFromAPI = async (input: {
|
|||
savedAt: new Date(),
|
||||
userId: input.userId,
|
||||
type: input.data.type,
|
||||
noteId,
|
||||
})
|
||||
.returning({ id: storedContent.id });
|
||||
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
CREATE UNIQUE INDEX `storedContent_baseUrl_unique` ON `storedContent` (`baseUrl`);
|
||||
|
|
@ -11,9 +11,10 @@
|
|||
"cf-typegen": "wrangler types --env-interface CloudflareEnv env.d.ts",
|
||||
"pages:build": "npx @cloudflare/next-on-pages",
|
||||
"preview": "npm run pages:build && wrangler pages dev",
|
||||
"deploy": "npm run pages:build && wrangler pages deploy",
|
||||
"deploy": "npm run pages:build && wrangler pages deploy --branch main",
|
||||
"schema-update": "bunx drizzle-kit generate sqlite",
|
||||
"update-local-db": "bunx wrangler d1 execute dev-d1-anycontext --local"
|
||||
"update-local-db": "bunx wrangler d1 execute dev-d1-anycontext --local",
|
||||
"update-prod-db": "bunx wrangler d1 execute prod-d1-supermemory --remote"
|
||||
},
|
||||
"dependencies": {
|
||||
"@million/lint": "^1.0.0-rc.11",
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ bucket_name = "dev-r2-anycontext"
|
|||
|
||||
[[d1_databases]]
|
||||
binding = "DATABASE"
|
||||
database_name = "prod-d1-supermemory"
|
||||
database_id = "f527a727-c472-41d4-8eaf-3d7ba0f2f395"
|
||||
database_name = "dev-d1-anycontext"
|
||||
database_id = "fc562605-157a-4f60-b439-2a24ffed5b4c"
|
||||
|
||||
[[env.production.d1_databases]]
|
||||
binding = "DATABASE"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue