- Frontend with Next.js, Tailwind CSS, and TypeScript was already setup.
- Installed Prisma
npm i prisma --save-dev.
- Initialized a new Prisma schema file
schema.prisma using npx prisma init.
- Formatted the schema.prisma file using
npx prisma format.
- Created a new postgres database in NeonDB and set the DATABASE_URL in the .env file.
- Installed Prisma Client using
npm i @prisma/client
- Created a migration with the name of "init" using
npx prisma migrate dev --name init.
- Deleted everything Related to Prisma...wait wait I will keep it for changelog but for blogs I will just use .md files and fs module to read them.
- Created a new directry named "content/posts" in the root directry, where all my posts will be stored.
- Created another directry named "src/lib" in the root directry, where all my utility functions will be stored.
- Created a new file named "posts.ts" in the "src/lib" directry, where I wrote a function to read all the sorted posts from the "src/content/posts" directry.
- Everything worked...Hooraayyy🥳
- I tried deploying my changes today but it crashed and gave 2 main issues: 1. Prisma Client version mismatch and 2. type issue in lib/posts.ts file.
- I fixed the Prisma Client version mismatch issue by deleting everything related to prisma🫠.
- And fixed the type issue by creating a new type named postMetaDate in the lib/posts.ts file.
- Deployed the changes and everything worked...Hooraayyy🥳
- Had issue with rendering MD files in the blog page, resolved using react-markdown & tailwind
- MDX, Next.js, React.js
- Lee blog source code
- Notion, Next.js, React
- Next.js blog tutorial
- Next-api-routes prisma example
- https://developer.chrome.com/docs/capabilities/browser-fs-access
generator client {
provider = "prisma-client-js"
}
datasource db {
provider = "postgresql"
url = env("DATABASE_URL")
}
model Posts {
id String @id @default(uuid())
createdAt DateTime @default(now())
updatedAt DateTime @updatedAt
title String
description String
content String
views Int @default(0)
}
model Project {
id String @id @default(uuid())
createdAt DateTime @default(now())
name String @db.VarChar(255)
description String
content String
duration Int
// userId String
// user User @relation(fields: [userId], references: [id])
updates Update[]
Tags Tag[]
}
model Tag {
id String @id @default(uuid())
name String
projectId String
project Project @relation(fields: [projectId], references: [id])
}
enum UPDATE_STATUS {
NOT_STARTED
IN_PROGRESS
SHIPPED
DEPRECATED
ARCHIVED
}
model Update {
id String @id @default(uuid())
createdAt DateTime @default(now())
title String
content String
status UPDATE_STATUS @default(NOT_STARTED)
version String?
asset String?
projectId String
project Project @relation(fields: [projectId], references: [id])
// updatePoints UpdatePoint[]
}
// model UpdatePoint {
// id String @id @default(uuid())
// createdAt DateTime @default(now())
// name String @db.VarChar(255)
// description String
// updateId String
// update Update @relation(fields: [updateId], references: [id])
// }