File tree Expand file tree Collapse file tree 6 files changed +260
-232
lines changed
(public-fullwidth)/author/[authorId]
api/public/post/[postIdOrSlug] Expand file tree Collapse file tree 6 files changed +260
-232
lines changed Original file line number Diff line number Diff line change 1- import "./globals.css"
1+ // import "./globals.css"
22
33import AuthProvider from "providers/authProvider"
44import { ToastContainer } from "react-toastify"
Original file line number Diff line number Diff line change 1+ import { getUserById } from "@/actions/public/authors"
2+ import FollowerItem from "@/molecules/follower/follower-item"
3+ import UserProfile from "@/molecules/follower/user-profile"
4+
5+ export const metadata = {
6+ title : "Follower" ,
7+ description : "List of followers" ,
8+ }
9+
10+ export default async function Page ( { params } : { params : { authorId : string } } ) {
11+ const author = await getUserById ( params ?. authorId as string )
12+
13+ return (
14+ < div className = "grid grid-cols-12 gap-10" >
15+ < UserProfile author = { author } />
16+ < div className = "col-span-8 flex flex-col gap-4" >
17+ < FollowerItem />
18+ </ div >
19+ </ div >
20+ )
21+ }
Original file line number Diff line number Diff line change 1+ import { getUserById } from "@/actions/public/authors"
2+ import UserProfile from "@/molecules/follower/user-profile"
3+ import PostItem from "@/molecules/posts/post-item"
4+
5+ export const metadata = {
6+ title : "Author" ,
7+ description : "A list of posts by the author" ,
8+ }
9+
10+ export default async function Page ( { params } : { params : { authorId : string } } ) {
11+ const author = await getUserById ( params ?. authorId as string )
12+
13+ return (
14+ < div className = "grid grid-cols-12 gap-10" >
15+ < UserProfile author = { author } />
16+ < div className = "col-span-8 rounded-md" >
17+ { author ?. post ?. map ( ( post ) => (
18+ < PostItem
19+ key = { post ?. id }
20+ post = { post }
21+ />
22+ ) ) }
23+ </ div >
24+ </ div >
25+ )
26+ }
Original file line number Diff line number Diff line change 1+ import { NextRequest } from "next/server"
2+
3+ import { postSelect } from "@/types/posts"
4+
5+ export async function GET ( request : NextRequest , { params } : { params : { postIdOrSlug : string } } ) {
6+ try {
7+ const post = await prisma . post . findUnique ( {
8+ where : {
9+ // postStatus: PostStatus.PUBLISHED,
10+ // id: params.postIdOrSlug,
11+ slug : params . postIdOrSlug ,
12+ // OR: [
13+ // {
14+ // id: params.postIdOrSlug,
15+ // },
16+ // {
17+ // slug: params.postIdOrSlug,
18+ // },
19+ // ],
20+ } ,
21+ select : postSelect ,
22+ } )
23+
24+ if ( ! post )
25+ return Response . json ( {
26+ status : 404 ,
27+ message : "Post not found" ,
28+ } )
29+
30+ return Response . json ( post , { status : 200 } )
31+ } catch ( error ) {
32+ return Response . error ( )
33+ }
34+ }
You can’t perform that action at this time.
0 commit comments