Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC] Nested Templates (and wrapping JavaScript with templates) #1895

Closed
wants to merge 59 commits into from

Conversation

jbolda
Copy link
Contributor

@jbolda jbolda commented Aug 23, 2017

This is a PR based on Issue #1866. Effectively updating createPages to accept an array of templates (and a javascript Post type of page). I got as much done as I could, and I probably won't be able to work on it for a while. Hopefully someone else can pick up where I left off. The using-javascript-transforms should be updated to work on this PR. I have been using it to test.

The remaining TODO as I am aware:

  • accept array for createPages component in develop
  • fix the props (and specifically props.data from graphql) as it gets all munged between the templates
  • gatsby build, ie have it run in production
  • update old tests
  • add tests for the new situations
  • dev 404 appears broken, fix
  • update using-javascript-transforms example templates to pull out blog post structure into overall component
  • update documentation

@gatsbybot
Copy link
Collaborator

Deploy preview ready!

Built with commit e049687

https://deploy-preview-1895--using-drupal.netlify.com

@gatsbybot
Copy link
Collaborator

gatsbybot commented Aug 23, 2017

Deploy preview ready!

Built with commit 2cefaeb

https://deploy-preview-1895--gatsbygram.netlify.com

@jbolda
Copy link
Contributor Author

jbolda commented Sep 19, 2017

Nearing the end of the tunnel here. The technical implementation for the template takes an array or coerces a string into an array. When creating the elements, we recursively loop through the array to best the components. The data is still per page, but it is now separated by keys based on the componentChunkName. The data is stored this way, but retrieved in a manner that returns the same data structure end result. The idea is for this to be compatible with any existing implementations.

I am keeping the TODO in the OP updated as I go.

@KyleAMathews
Copy link
Contributor

Hey just had a quick look at this and wanted to correct a miscommunication. We want nested layout components not nested page components. It's perhaps more semantics than anything else but there can only be one page component controlling the page at a time. The boundary that's significant is between pages and layouts as layouts stay constant across page changes which lets you retain state in the layout as you click between pages. Having nested page components doesn't gain you anything because you can already nest components quite easily yourself.

@KyleAMathews
Copy link
Contributor

On train writing on my phone so happy to discuss at more length later :-)

@jbolda jbolda changed the title [WIP] Nested Templates (and wrapping JavaScript with templates) [RFC] Nested Templates (and wrapping JavaScript with templates) Sep 26, 2017
@jbolda
Copy link
Contributor Author

jbolda commented Sep 26, 2017

This is substantially complete sans documentation. The discussion is in #1866 (and follow-ups to @KyleAMathews comment above). Comments, code reviews, and testing on your own website are welcome. The idea is that this is effectively backward compatible to existing websites (no breaking changes). I can update documentation when the current implementation is greenlit.

@jbolda
Copy link
Contributor Author

jbolda commented Sep 28, 2017

Closed per discussion on #1866.

@jbolda jbolda closed this Sep 28, 2017
@nihgwu
Copy link
Contributor

nihgwu commented Sep 28, 2017

Can we make it a plugin instead of putting in core? I really appreciate your efforts on this great feature

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants