51 lines
1.8 KiB
JavaScript
51 lines
1.8 KiB
JavaScript
import { SearchLayout } from '@/components/layout'
|
|
import { getGetServerSideProps } from '@/api/ssrApollo'
|
|
import { useRouter } from 'next/router'
|
|
import { SUB_SEARCH } from '@/fragments/subs'
|
|
import Items from '@/components/items'
|
|
import styles from '@/styles/search.module.css'
|
|
|
|
export const getServerSideProps = getGetServerSideProps({
|
|
query: SUB_SEARCH,
|
|
notFound: (data, vars) => vars.sub && !data.sub
|
|
})
|
|
|
|
export default function Index ({ ssrData }) {
|
|
const router = useRouter()
|
|
const variables = { ...router.query, includeComments: true }
|
|
|
|
const sub = ssrData?.sub?.name || variables.sub
|
|
|
|
return (
|
|
<SearchLayout sub={sub}>
|
|
{variables.q
|
|
? <Items
|
|
ssrData={ssrData}
|
|
query={SUB_SEARCH}
|
|
destructureData={data => data.search}
|
|
variables={variables}
|
|
noMoreText='NO MORE'
|
|
/>
|
|
: (
|
|
<div className={styles.content}>
|
|
<div className={styles.box}>
|
|
<div className={styles.header}>
|
|
<div className='text-muted text-center' style={{ fontFamily: 'lightning', fontSize: '2rem', opacity: '0.75' }}>
|
|
filters
|
|
</div>
|
|
</div>
|
|
<div className={styles.body}>
|
|
<ul className={styles.inner}>
|
|
<li><b>@</b>​<em>nym</em> - limit to results authored by nym</li>
|
|
<li><b>~</b>​<em>territory</em> - limit to results from territory</li>
|
|
<li><b>url:</b>​<em>stacker​.news</em> - limit to link posts from a specific url</li>
|
|
<li><b>"</b><em>exact phrase</em><b>"</b> - limit to results that contain an exact phrase</li>
|
|
</ul>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
)}
|
|
</SearchLayout>
|
|
)
|
|
}
|