File tree Expand file tree Collapse file tree 2 files changed +69
-23
lines changed
Expand file tree Collapse file tree 2 files changed +69
-23
lines changed Original file line number Diff line number Diff line change @@ -10,23 +10,27 @@ import {
1010 queryPagePreview ,
1111} from "~/types" ;
1212
13- export const getStaticProps : GetStaticProps = async ( {
14- preview,
15- previewData,
16- locale,
17- params,
18- } : {
19- preview : boolean ;
20- previewData : {
21- contentType : string ;
22- token : string ;
23- } ;
24- locale : string ;
25- params : {
26- slug ?: string ;
27- } ;
28- } ) => {
29- const client = getApolloClient ( ) ;
13+ export const getProps = async (
14+ {
15+ preview,
16+ previewData,
17+ locale,
18+ params,
19+ } : {
20+ preview : boolean ;
21+ previewData : {
22+ contentType : string ;
23+ token : string ;
24+ } ;
25+ locale : string ;
26+ params : {
27+ slug ?: string ;
28+ } ;
29+ } ,
30+ clientParam = null ,
31+ revalidate = null ,
32+ ) => {
33+ const client = clientParam || getApolloClient ( ) ;
3034 const slug = params ?. slug as string ;
3135
3236 const [ _ , pageDataQuery ] = await Promise . all ( [
@@ -61,11 +65,19 @@ export const getStaticProps: GetStaticProps = async ({
6165
6266 await dataFetching ;
6367
64- return addApolloState ( client , {
65- props : {
66- blocksProps : staticProps ,
67- isPreview : preview || false ,
68- previewData : previewData || null ,
68+ return addApolloState (
69+ client ,
70+ {
71+ props : {
72+ blocksProps : staticProps ,
73+ isPreview : preview || false ,
74+ previewData : previewData || null ,
75+ } ,
6976 } ,
70- } ) ;
77+ revalidate ,
78+ ) ;
79+ } ;
80+
81+ export const getStaticProps : GetStaticProps = async ( context : any ) => {
82+ return getProps ( context ) ;
7183} ;
Original file line number Diff line number Diff line change 1+ import type { GetServerSideProps } from "next" ;
2+ import { useRouter } from "next/router" ;
3+ import { getApolloClient } from "~/apollo/client" ;
4+ import { PageHandler } from "~/components/page-handler" ;
5+ import { getProps } from "~/components/page-handler/page-static-props" ;
6+
7+ export const HotelsPage = ( { blocksProps, isPreview, previewData } ) => {
8+ const router = useRouter ( ) ;
9+ return (
10+ < PageHandler
11+ isPreview = { isPreview }
12+ previewData = { previewData }
13+ slug = "hotels"
14+ blocksProps = { blocksProps }
15+ />
16+ ) ;
17+ } ;
18+
19+ export const getServerSideProps : GetServerSideProps = async ( context : any ) => {
20+ const { req } = context ;
21+ const client = getApolloClient ( null , req . cookies ) ;
22+ return getProps (
23+ {
24+ ...context ,
25+ params : {
26+ slug : "hotels" ,
27+ } ,
28+ } ,
29+ client ,
30+ null ,
31+ ) ;
32+ } ;
33+
34+ export default HotelsPage ;
You can’t perform that action at this time.
0 commit comments