This commit is contained in:
Max Leiter 2022-11-29 22:22:17 -08:00
parent ce0c442273
commit 44a05f6456
3 changed files with 11 additions and 8 deletions

View file

@ -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(

View file

@ -1,5 +1,5 @@
import PageSeo from "@components/page-seo"
export default function NewPostHead() {
return <PageSeo title="Create a new Drift" />
return <PageSeo title="New" />
}

View file

@ -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 = {
@ -11,7 +11,9 @@ export type PostProps = {
// export async function generateStaticParams() {
// const posts = await getAllPosts({
// where: {
// visibility: "public"
// visibility: {
// in: ["public", "unlisted"]
// }
// }
// })
@ -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") {