2023-07-23 15:08:43 +00:00
|
|
|
import { getGetServerSideProps } from '../../api/ssrApollo'
|
|
|
|
import { SUB } from '../../fragments/subs'
|
|
|
|
import { CenterLayout } from '../../components/layout'
|
|
|
|
import Post from '../../components/post'
|
|
|
|
import { useQuery } from '@apollo/client'
|
|
|
|
import { useRouter } from 'next/router'
|
|
|
|
import PageLoading from '../../components/page-loading'
|
|
|
|
|
2023-08-28 17:52:15 +00:00
|
|
|
export const getServerSideProps = getGetServerSideProps({
|
|
|
|
query: SUB,
|
|
|
|
notFound: (data, vars) => vars.sub && !data.sub
|
|
|
|
})
|
2023-07-23 15:08:43 +00:00
|
|
|
|
|
|
|
export default function PostPage ({ ssrData }) {
|
|
|
|
const router = useRouter()
|
|
|
|
const { data } = useQuery(SUB, { variables: { sub: router.query.sub } })
|
|
|
|
if (!data && !ssrData) return <PageLoading />
|
|
|
|
|
|
|
|
const { sub } = data || ssrData
|
|
|
|
|
|
|
|
return (
|
|
|
|
<CenterLayout sub={sub?.name}>
|
|
|
|
<Post sub={sub} />
|
|
|
|
</CenterLayout>
|
|
|
|
)
|
|
|
|
}
|