Created
February 16, 2021 10:26
-
-
Save JamieMason/ca8bfa0370873ba9cc0d6cbcae3db63e to your computer and use it in GitHub Desktop.
TODO getServerSideProps leaking server deps into client bundle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import type { GetServerSideProps, NextPage } from 'next'; | |
import Head from 'next/head'; | |
import React from 'react'; | |
import { SearchPageComponent } from './search-page-component'; | |
import type { Props } from './search-page-props'; | |
export const getServerSideProps: GetServerSideProps<Props> = async (ctx) => { | |
try { | |
if (typeof window === 'undefined') { | |
const { getSearchPageProps } = await import('./search-page-props'); | |
const props = await getSearchPageProps(ctx); | |
return { props }; | |
} | |
} catch (err) { | |
return { notFound: true }; | |
} | |
return { notFound: true }; | |
}; | |
export const SearchPage: NextPage<Props> = ({ algoliaListing, searchPage, siteLayout }) => ( | |
<React.Fragment> | |
<Head> | |
<title>{searchPage.meta.title}</title> | |
<meta content={searchPage.meta.description} name="description" /> | |
<link href={searchPage.meta.canonical} rel="canonical" /> | |
</Head> | |
<SearchPageComponent | |
algoliaListing={algoliaListing} | |
searchPage={searchPage} | |
siteLayout={siteLayout} | |
/> | |
</React.Fragment> | |
); | |
export default SearchPage; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment