stacker.news/pages/~/index.js

45 lines
1.5 KiB
JavaScript
Raw Normal View History

import { useRouter } from 'next/router'
import { getGetServerSideProps } from '@/api/ssrApollo'
import Items from '@/components/items'
import Layout from '@/components/layout'
import { SUB_FULL, SUB_ITEMS } from '@/fragments/subs'
import Snl from '@/components/snl'
2023-11-21 23:32:22 +00:00
import { useQuery } from '@apollo/client'
import PageLoading from '@/components/page-loading'
import TerritoryHeader from '@/components/territory-header'
2024-03-31 21:53:57 +00:00
import Link from 'next/link'
export const getServerSideProps = getGetServerSideProps({
query: SUB_ITEMS,
notFound: (data, vars) => vars.sub && !data.sub
})
export default function Sub ({ ssrData }) {
const router = useRouter()
const variables = { ...router.query }
2023-11-21 23:32:22 +00:00
const { data } = useQuery(SUB_FULL, { variables })
if (!data && !ssrData) return <PageLoading />
const { sub } = data || ssrData
return (
2024-01-04 03:15:54 +00:00
<Layout sub={sub?.name}>
2023-11-21 23:32:22 +00:00
{sub
2023-12-15 18:10:29 +00:00
? <TerritoryHeader sub={sub} />
2023-11-21 23:32:22 +00:00
: (
<>
<Snl />
</>)}
2024-03-31 21:53:57 +00:00
<small className='pb-3 px-1 text-muted' style={{ marginTop: '-0.25rem', lineHeight: 1.5 }}>
<Link className='text-reset' href='/rewards' style={{ textDecoration: 'underline' }}>
Million Sat Madness
</Link> is sponsored by{' '}
2024-04-01 13:53:57 +00:00
<Link className='text-reset' href='https://btcplusplus.dev/conf/atx24?ref=stackernews' target='_blank' rel='noreferrer' style={{ textDecoration: 'underline' }}>
the Bitcoin++ Conference in Austin May 1-4
2024-03-31 21:53:57 +00:00
</Link>
</small>
2023-07-25 14:14:45 +00:00
<Items ssrData={ssrData} variables={variables} />
</Layout>
)
}