stacker.news/pages/[username]/comments.js

46 lines
977 B
JavaScript
Raw Normal View History

2021-04-22 22:14:32 +00:00
import Layout from '../../components/layout'
import { gql } from '@apollo/client'
import ApolloClient from '../../api/client'
import UserHeader from '../../components/user-header'
2021-06-24 23:56:01 +00:00
import CommentsFlat from '../../components/comments-flat'
2021-07-08 00:15:27 +00:00
import Seo from '../../components/seo'
2021-04-22 22:14:32 +00:00
2021-04-27 00:55:48 +00:00
export async function getServerSideProps ({ req, params }) {
const { error, data: { user } } = await (await ApolloClient(req)).query({
2021-04-22 22:14:32 +00:00
query:
gql`{
user(name: "${params.username}") {
id
createdAt
name
nitems
ncomments
stacked
sats
}
}`
})
if (!user || error) {
return {
notFound: true
}
}
return {
props: {
user
}
}
}
2021-06-24 23:56:01 +00:00
export default function UserComments ({ user }) {
2021-04-22 22:14:32 +00:00
return (
2021-07-08 00:34:23 +00:00
<Layout noSeo>
2021-07-08 00:15:27 +00:00
<Seo user={user} />
2021-04-22 22:14:32 +00:00
<UserHeader user={user} />
2021-08-17 23:59:22 +00:00
<CommentsFlat variables={{ userId: user.id }} includeParent noReply />
2021-04-22 22:14:32 +00:00
</Layout>
)
}