@@ -283,12 +283,12 @@ export default async function staticPage({
283
283
}
284
284
) . pop ( )
285
285
286
+ const slicesContext = {
287
+ // if we're in build now, we know we're on the server
288
+ // otherwise we're in an engine
289
+ renderEnvironment : renderContext . isDuringBuild ? `server` : `engines` ,
290
+ }
286
291
if ( process . env . GATSBY_SLICES ) {
287
- const slicesContext = {
288
- // if we're in build now, we know we're on the server
289
- // otherwise we're in an engine
290
- renderEnvironment : renderContext . isDuringBuild ? `server` : `engines` ,
291
- }
292
292
// if we're running in an engine, we need to manually wrap body with
293
293
// the results context to pass the map of slice name to component/data/context
294
294
if ( slicesContext . renderEnvironment === `engines` ) {
@@ -509,7 +509,7 @@ export default async function staticPage({
509
509
pathPrefix : __PATH_PREFIX__ ,
510
510
} )
511
511
512
- const html = `<!DOCTYPE html> ${ renderToStaticMarkup (
512
+ let htmlElement = (
513
513
< Html
514
514
{ ...bodyProps }
515
515
headComponents = { headComponents }
@@ -520,7 +520,17 @@ export default async function staticPage({
520
520
body = { bodyHtml }
521
521
path = { pagePath }
522
522
/>
523
- ) } `
523
+ )
524
+
525
+ if ( process . env . GATSBY_SLICES ) {
526
+ htmlElement = (
527
+ < SlicesContext . Provider value = { slicesContext } >
528
+ { htmlElement }
529
+ </ SlicesContext . Provider >
530
+ )
531
+ }
532
+
533
+ const html = `<!DOCTYPE html>${ renderToStaticMarkup ( htmlElement ) } `
524
534
525
535
return {
526
536
html,
0 commit comments