stacker.news/pages/top/comments/[when].js

26 lines
845 B
JavaScript
Raw Normal View History

2021-12-16 23:05:31 +00:00
import Layout from '../../../components/layout'
import { useRouter } from 'next/router'
import { getGetServerSideProps } from '../../../api/ssrApollo'
import TopHeader from '../../../components/top-header'
2022-10-25 21:35:32 +00:00
import { TOP_COMMENTS } from '../../../fragments/comments'
2021-12-16 23:05:31 +00:00
import CommentsFlat from '../../../components/comments-flat'
2022-10-25 21:35:32 +00:00
export const getServerSideProps = getGetServerSideProps(TOP_COMMENTS)
2021-12-16 23:05:31 +00:00
2022-10-25 21:35:32 +00:00
export default function Index ({ data: { topComments: { comments, cursor } } }) {
2021-12-16 23:05:31 +00:00
const router = useRouter()
return (
<Layout>
<TopHeader cat='comments' />
<CommentsFlat
comments={comments} cursor={cursor}
2022-10-25 21:35:32 +00:00
query={TOP_COMMENTS}
destructureData={data => data.topComments}
variables={{ sort: router.query.sort, when: router.query.when }}
2021-12-16 23:05:31 +00:00
includeParent noReply
/>
</Layout>
)
}