index.tsx raw

   1  import Relay from '@/components/Relay'
   2  import SecondaryPageLayout from '@/layouts/SecondaryPageLayout'
   3  import { normalizeUrl, simplifyUrl } from '@/lib/url'
   4  import { forwardRef, useMemo } from 'react'
   5  import NotFoundPage from '../NotFoundPage'
   6  
   7  const RelayPage = forwardRef(({ url, index }: { url?: string; index?: number }, ref) => {
   8    const normalizedUrl = useMemo(() => (url ? normalizeUrl(url) : undefined), [url])
   9    const title = useMemo(() => (url ? simplifyUrl(url) : undefined), [url])
  10  
  11    if (!normalizedUrl) {
  12      return <NotFoundPage ref={ref} />
  13    }
  14  
  15    return (
  16      <SecondaryPageLayout ref={ref} index={index} title={title} displayScrollToTopButton>
  17        <Relay url={normalizedUrl} />
  18      </SecondaryPageLayout>
  19    )
  20  })
  21  RelayPage.displayName = 'RelayPage'
  22  export default RelayPage
  23