diff --git a/client/app/(posts)/new/components/new.tsx b/client/app/(posts)/new/components/new.tsx
index 68674719..7b743389 100644
--- a/client/app/(posts)/new/components/new.tsx
+++ b/client/app/(posts)/new/components/new.tsx
@@ -37,7 +37,8 @@ const Post = ({
initialPost?: string
newPostParent?: string
}) => {
- const initialPost = JSON.parse(stringifiedInitialPost || "{}") as PostWithFiles
+ const parsedPost = JSON.parse(stringifiedInitialPost || "{}")
+ const initialPost = parsedPost?.id ? parsedPost : null
const { setToast } = useToasts()
const router = useRouter()
const [title, setTitle] = useState(
diff --git a/client/app/(posts)/new/head.tsx b/client/app/(posts)/new/head.tsx
index 8acc8e7d..d50d5422 100644
--- a/client/app/(posts)/new/head.tsx
+++ b/client/app/(posts)/new/head.tsx
@@ -1,5 +1,5 @@
import PageSeo from "@components/page-seo"
export default function NewPostHead() {
- return
+ return
}
diff --git a/client/app/(posts)/post/[id]/page.tsx b/client/app/(posts)/post/[id]/page.tsx
index 2c5156f1..189d5d70 100644
--- a/client/app/(posts)/post/[id]/page.tsx
+++ b/client/app/(posts)/post/[id]/page.tsx
@@ -1,6 +1,6 @@
import PostPage from "app/(posts)/post/[id]/components/post-page"
import { notFound, redirect } from "next/navigation"
-import { getPostById, Post } from "@lib/server/prisma"
+import { getAllPosts, getPostById, Post } from "@lib/server/prisma"
import { getCurrentUser } from "@lib/server/session"
export type PostProps = {
@@ -10,9 +10,11 @@ export type PostProps = {
// export async function generateStaticParams() {
// const posts = await getAllPosts({
-// where: {
-// visibility: "public"
-// }
+// where: {
+// visibility: {
+// in: ["public", "unlisted"]
+// }
+// }
// })
// return posts.map((post) => ({
@@ -25,12 +27,12 @@ const getPost = async (id: string) => {
withFiles: true,
withAuthor: true
})
- const user = await getCurrentUser()
if (!post) {
return notFound()
}
-
+
+ const user = await getCurrentUser()
const isAuthorOrAdmin = user?.id === post?.authorId || user?.role === "admin"
if (post.visibility === "public") {