mirror of https://github.com/MaxLeiter/Drift
				
				
				
			
			You cannot select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
		
			
		
			
				
	
	
		
			35 lines
		
	
	
		
			651 B
		
	
	
	
		
			TypeScript
		
	
			
		
		
	
	
			35 lines
		
	
	
		
			651 B
		
	
	
	
		
			TypeScript
		
	
import NewPost from "../../components/new"
 | 
						|
import { notFound, redirect } from "next/navigation"
 | 
						|
import { getPostById } from "@lib/server/prisma"
 | 
						|
import { getSession } from "@lib/server/session"
 | 
						|
 | 
						|
const NewFromExisting = async ({
 | 
						|
	params
 | 
						|
}: {
 | 
						|
	params: {
 | 
						|
		id: string
 | 
						|
	}
 | 
						|
}) => {
 | 
						|
	const session = await getSession()
 | 
						|
	if (!session?.user) {
 | 
						|
		return redirect("/signin")
 | 
						|
	}
 | 
						|
 | 
						|
	const { id } = params
 | 
						|
 | 
						|
	if (!id) {
 | 
						|
		return notFound()
 | 
						|
	}
 | 
						|
 | 
						|
	const post = await getPostById(id, {
 | 
						|
		withFiles: true,
 | 
						|
		withAuthor: false
 | 
						|
	})
 | 
						|
	
 | 
						|
	const serialized = JSON.stringify(post)
 | 
						|
 | 
						|
	return <NewPost initialPost={serialized} newPostParent={id} />
 | 
						|
}
 | 
						|
 | 
						|
export default NewFromExisting
 |