From 92837fb74fd90ebfb3e1d4f5d2e0ce894e55689a Mon Sep 17 00:00:00 2001 From: Izan Gil <66965250+SrIzan10@users.noreply.github.com> Date: Sun, 5 Jan 2025 18:04:37 +0100 Subject: [PATCH] feat: image previews --- README.md | 25 +++---------------- next.config.mjs | 7 +++++- package.json | 1 + .../20250105130053_add_preview/migration.sql | 8 ++++++ prisma/schema.prisma | 15 +++++------ src/app/(public)/post/[id]/page.tsx | 16 ++++++++---- src/app/globals.css | 4 +-- src/components/app/NavBar/NavBar.tsx | 3 +-- src/lib/form/actions.ts | 10 ++++++-- src/lib/form/zod.ts | 2 +- src/lib/hashImage.ts | 16 ++++++++++++ 11 files changed, 65 insertions(+), 42 deletions(-) create mode 100644 prisma/migrations/20250105130053_add_preview/migration.sql create mode 100644 src/lib/hashImage.ts diff --git a/README.md b/README.md index ee9e163..a52a9de 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,5 @@ -# Sr Izan Stack +# nextbooru -Sr Izan Stack is a next.js template which runs on modern technologies, with a focus on developer experience and ease-of-use. +Nextbooru is a simple image board software written with modern web technologies. It is designed to be fast and clean. -## The stack - -- Framework: [Next.js](https://nextjs.org/) -- Language: [TypeScript](https://www.typescriptlang.org/) -- Styling: [Tailwind CSS](https://tailwindcss.com/) -- UI Library: [shadcn/ui](https://ui.shadcn.com) -- Authentication: [Lucia](https://lucia-auth.com) -- Deployment: [Vercel](https://vercel.com) -- Database: [Supabase Postgres](https://supabase.com) with [Prisma](https://www.prisma.io/) - -## Why (insert tool here)? - -- **Next.js**: I like the next.js app router because it has a very good developer experience and it's very easy to use. -- **TypeScript**: Don't even need to explain why -- **Tailwind CSS**: I like the utility-first approach and the speed of development it provides -- **shadcn/ui**: Copy-pasting components is so fire (also is Radix UI) -- **Lucia**: The DevEX is amazing and it's very easy to use -- **Vercel**: Next.js and Vercel are like bread and butter, but it's a bit slow with the free tier. -- **MongoDB Atlas**: It has a very generous free tier, and I'm choosing NoSQL because Postgres hates me. -- **Prisma**: Even though there are solid competitors like Drizzle, Prisma is easy to use, understand, and fast enough for my use case. \ No newline at end of file +The software is very unstable and is not recommended for production use. For now, a testing server is available at [nextbooru.srizan.dev](https://nextbooru.srizan.dev). \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index b5bcefb..40d063c 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -3,7 +3,12 @@ const nextConfig = { webpack: (config) => { config.externals.push("@node-rs/argon2"); return config; - } + }, + experimental: { + serverActions: { + bodySizeLimit: '20mb' + } + } }; export default nextConfig; diff --git a/package.json b/package.json index c21a5bd..c846d99 100644 --- a/package.json +++ b/package.json @@ -31,6 +31,7 @@ "react": "19", "react-dom": "19", "react-hook-form": "^7.54.2", + "sharp": "^0.33.5", "sonner": "^1.4.41", "tailwind-merge": "^2.2.2", "tailwindcss-animate": "^1.0.7", diff --git a/prisma/migrations/20250105130053_add_preview/migration.sql b/prisma/migrations/20250105130053_add_preview/migration.sql new file mode 100644 index 0000000..61fa09a --- /dev/null +++ b/prisma/migrations/20250105130053_add_preview/migration.sql @@ -0,0 +1,8 @@ +/* + Warnings: + + - Added the required column `previewHash` to the `Post` table without a default value. This is not possible if the table is not empty. + +*/ +-- AlterTable +ALTER TABLE "Post" ADD COLUMN "previewHash" TEXT NOT NULL; diff --git a/prisma/schema.prisma b/prisma/schema.prisma index 958608c..55065e2 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -29,11 +29,12 @@ model Session { } model Post { - id String @id @default(cuid()) - imageUrl String - caption String - createdAt DateTime @default(now()) - tags String[] - authorId String - author User @relation(references: [id], fields: [authorId], onDelete: Cascade) + id String @id @default(cuid()) + imageUrl String + caption String + createdAt DateTime @default(now()) + tags String[] + authorId String + author User @relation(references: [id], fields: [authorId], onDelete: Cascade) + previewHash String } diff --git a/src/app/(public)/post/[id]/page.tsx b/src/app/(public)/post/[id]/page.tsx index 779b9c6..fa86bde 100644 --- a/src/app/(public)/post/[id]/page.tsx +++ b/src/app/(public)/post/[id]/page.tsx @@ -10,7 +10,7 @@ export default async function Page({ params }: { params: Promise<{ id: string }> const { id } = await params; const post = await prisma.post.findUnique({ where: { id }, include: { author: true } }); if (!post) { - return
{post.caption}
+