Gatsby: Pass in components for <Body /> <HeadComponents /> and <PostBodyComponents />

Created on 7 Jun 2017  Â·  7Comments  Â·  Source: gatsbyjs/gatsby

@iiroj suggested this to me and I really like it.

That'd make things in html.js more "react-y" and more foolproof as it'd make these things opaque data containers as generally they should be.

I think we could leave the existing props headComponents, postBodyComponents, and body for backwards compatability + people might want to manipulate their data before rendering.

help wanted stale?

Most helpful comment

Right now an html.js looks like (greatly simplified)

<html>
  <head>
    {this.props.headComponents}
  </head>
  <body>
    <div
       id="___gatsby"
       dangerouslySetInnerHTML={{ __html: this.props.body }}
     />
    {this.props.postBodyComponents}
  </body>
</html>

Instead it could be:

<html>
  <head>
    <HeadComponents />
  </head>
  <body>
    <PageBody />
    <PostBodyComponents />
  </body>
</html>

Much simpler.

All 7 comments

I am not sure what you mean by this. Care to explain a little further maybe?

Right now an html.js looks like (greatly simplified)

<html>
  <head>
    {this.props.headComponents}
  </head>
  <body>
    <div
       id="___gatsby"
       dangerouslySetInnerHTML={{ __html: this.props.body }}
     />
    {this.props.postBodyComponents}
  </body>
</html>

Instead it could be:

<html>
  <head>
    <HeadComponents />
  </head>
  <body>
    <PageBody />
    <PostBodyComponents />
  </body>
</html>

Much simpler.

I was actually thinking more along the lines of if they're not passed in as props, where do they come from? But I am guessing they would simply be imported and themselves get the content from the store.

It's def much cleaner to look at :)

Oh they would be passed in as props. Sorry for not making that clear.

On Wed, Jun 7, 2017, 9:56 AM Thijs Koerselman notifications@github.com
wrote:

I was actually thinking more along the lines of if they're not passed in
as props, where do they come from? But I am guessing they would simply be
imported and themselves get the content from the store.

It's def much cleaner to look at :)

—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/gatsbyjs/gatsby/issues/1121#issuecomment-306857769,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AAEVh9xMEvHdxgawGs7Z2NIH20dvknhbks5sBtZZgaJpZM4Ny7BO
.

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

This got done a long time ago :-)

@KyleAMathews I am little puzzled on how I would pass values to {this.props.headComponents}.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

3CordGuy picture 3CordGuy  Â·  3Comments

ghost picture ghost  Â·  3Comments

KyleAMathews picture KyleAMathews  Â·  3Comments

kalinchernev picture kalinchernev  Â·  3Comments

benstr picture benstr  Â·  3Comments