@@ -8,43 +8,21 @@ import availableTemplates from '@/wp-templates';
88export default function Page ( props ) {
99 const { templateData } = props ;
1010
11- if ( ! templateData ?. template ?. id ) {
12- return (
13- < div style = { { padding : '20px' , textAlign : 'center' } } >
14- < h1 style = { { color : 'red' } } > Template not found</ h1 >
15- < p > No template could be resolved for this URI.</ p >
16- </ div >
17- ) ;
18- }
19-
20- const PageTemplate = availableTemplates [ templateData . template . id ] ;
21-
22- if ( ! PageTemplate ) {
23- return (
24- < div style = { { padding : '20px' , textAlign : 'center' } } >
25- < h1 style = { { color : 'red' } } > Component not found</ h1 >
26- < p > Template "{ templateData . template . id } " is not available.</ p >
27- < pre
28- style = { { textAlign : 'left' , background : '#f5f5f5' , padding : '10px' } } >
29- { JSON . stringify ( templateData , null , 2 ) }
30- </ pre >
31- </ div >
32- ) ;
33- }
11+ const PageTemplate = availableTemplates [ templateData ?. template ?. id ] ;
3412
3513 return < PageTemplate { ...props } /> ;
3614}
3715
3816export async function getServerSideProps ( context ) {
3917 const { params } = context ;
4018
19+ const client = createDefaultClient ( process . env . WORDPRESS_URL ) ;
20+ setGraphQLClient ( client ) ;
21+
4122 const uri = Array . isArray ( params ?. uri )
4223 ? '/' + params . uri . join ( '/' ) + '/'
4324 : '/' ;
4425
45- const client = createDefaultClient ( process . env . WORDPRESS_URL ) ;
46- setGraphQLClient ( client ) ;
47-
4826 try {
4927 const templateData = await uriToTemplate ( {
5028 uri,
0 commit comments