|
|
|
@ -1,6 +1,6 @@
|
|
|
|
import PostPage from "app/(posts)/post/[id]/components/post-page"
|
|
|
|
import PostPage from "app/(posts)/post/[id]/components/post-page"
|
|
|
|
import { notFound, redirect } from "next/navigation"
|
|
|
|
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"
|
|
|
|
import { getCurrentUser } from "@lib/server/session"
|
|
|
|
|
|
|
|
|
|
|
|
export type PostProps = {
|
|
|
|
export type PostProps = {
|
|
|
|
@ -10,9 +10,11 @@ export type PostProps = {
|
|
|
|
|
|
|
|
|
|
|
|
// export async function generateStaticParams() {
|
|
|
|
// export async function generateStaticParams() {
|
|
|
|
// const posts = await getAllPosts({
|
|
|
|
// const posts = await getAllPosts({
|
|
|
|
// where: {
|
|
|
|
// where: {
|
|
|
|
// visibility: "public"
|
|
|
|
// visibility: {
|
|
|
|
// }
|
|
|
|
// in: ["public", "unlisted"]
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
|
|
// return posts.map((post) => ({
|
|
|
|
// return posts.map((post) => ({
|
|
|
|
@ -25,12 +27,12 @@ const getPost = async (id: string) => {
|
|
|
|
withFiles: true,
|
|
|
|
withFiles: true,
|
|
|
|
withAuthor: true
|
|
|
|
withAuthor: true
|
|
|
|
})
|
|
|
|
})
|
|
|
|
const user = await getCurrentUser()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!post) {
|
|
|
|
if (!post) {
|
|
|
|
return notFound()
|
|
|
|
return notFound()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const user = await getCurrentUser()
|
|
|
|
const isAuthorOrAdmin = user?.id === post?.authorId || user?.role === "admin"
|
|
|
|
const isAuthorOrAdmin = user?.id === post?.authorId || user?.role === "admin"
|
|
|
|
|
|
|
|
|
|
|
|
if (post.visibility === "public") {
|
|
|
|
if (post.visibility === "public") {
|
|
|
|
|