stacker.news/pages/items/[id]/index.js

28 lines
805 B
JavaScript
Raw Normal View History

2021-09-30 15:46:58 +00:00
import Layout from '../../../components/layout'
import { ITEM_FULL } from '../../../fragments/items'
import Seo from '../../../components/seo'
import ItemFull from '../../../components/item-full'
2021-10-26 20:49:37 +00:00
import { getGetServerSideProps } from '../../../api/ssrApollo'
2021-09-30 15:46:58 +00:00
import { useQuery } from '@apollo/client'
export const getServerSideProps = getGetServerSideProps(ITEM_FULL, null,
data => !data.item || (data.item.status !== 'ACTIVE' && !data.item.mine))
2021-09-30 15:46:58 +00:00
2021-10-26 20:49:37 +00:00
export default function AnItem ({ data: { item } }) {
const { data } = useQuery(ITEM_FULL, {
variables: { id: item.id }
2021-09-30 15:46:58 +00:00
})
if (data) {
({ item } = data)
}
2022-02-17 17:23:43 +00:00
const sub = item.sub?.name || item.root?.sub?.name
2021-09-30 15:46:58 +00:00
return (
2022-02-17 17:23:43 +00:00
<Layout sub={sub} noSeo>
<Seo item={item} sub={sub} />
2021-09-30 15:46:58 +00:00
<ItemFull item={item} />
</Layout>
)
}