stacker.news/pages/[name]/posts.js

32 lines
937 B
JavaScript
Raw Normal View History

2021-10-26 20:49:37 +00:00
import Layout from '../../components/layout'
import { useQuery } from '@apollo/client'
import UserHeader from '../../components/user-header'
import Seo from '../../components/seo'
import Items from '../../components/items'
import { USER_WITH_POSTS } from '../../fragments/users'
import { getGetServerSideProps } from '../../api/ssrApollo'
2022-02-17 17:23:43 +00:00
export const getServerSideProps = getGetServerSideProps(USER_WITH_POSTS)
2021-10-26 20:49:37 +00:00
2022-02-17 17:23:43 +00:00
export default function UserPosts ({ data: { user, items: { items, cursor } } }) {
2021-10-26 20:49:37 +00:00
const { data } = useQuery(USER_WITH_POSTS,
{ variables: { name: user.name, sort: 'user' } })
2021-10-26 20:49:37 +00:00
if (data) {
2022-02-17 17:23:43 +00:00
({ user, items: { items, cursor } } = data)
2021-10-26 20:49:37 +00:00
}
return (
<Layout noSeo>
<Seo user={user} />
<UserHeader user={user} />
2021-11-12 22:39:52 +00:00
<div className='mt-2'>
<Items
items={items} cursor={cursor}
variables={{ name: user.name, sort: 'user' }}
2021-11-12 22:39:52 +00:00
/>
</div>
2021-10-26 20:49:37 +00:00
</Layout>
)
}