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

[Gutenberg Starter Theme] Try pulling starter content in from an external file #16

Closed
wants to merge 1 commit into from

Conversation

kjellr
Copy link
Collaborator

@kjellr kjellr commented Jan 31, 2020

This PR tries out an idea that came up during a discussion with @epiqueras yesterday — that starter content could theoretically be pulled in from a standalone "block template"-style file, rather than being declared as a complicated array in PHP, as is done in themes like this repo's version of Twenty Twenty.

This PR creates a new block-starter-content folder for the Gutenberg Starter Theme (Blocks). It contains a post-demo.html file, full of the content from Gutenberg's demo post. This content gets pulled into the homepage via file_get_contents() for now. I'm not sure if that's the right function, or if it needs to be escaped and/or limited in some way... I could see this being problematic if the file size were huge. But it appears to work for this example at least. I'd love some more experienced PHP 👀 on that method.

To test:

  1. Start a brand new WordPress site.
  2. Clone this repository or upload a zip of the Gutenberg Starter Theme (Blocks) into your site’s themes directory.
  3. Install the Gutenberg plugin.
  4. Enable the "Full Site Editing" experiment in the Gutenberg > Experiments panel.
  5. Activate the new theme from within Appearance > Themes.
  6. Visit the Customizer to automatically load the demo content.

The homepage should now contain the demo content from block-starter-content/post-demo.html.


Screenshot

Screen Shot 2020-01-31 at 4 11 30 PM

@kjellr kjellr added the enhancement New feature or request label Jan 31, 2020
@kjellr kjellr requested review from allancole and jffng January 31, 2020 21:14
@kjellr kjellr self-assigned this Jan 31, 2020
Copy link
Collaborator

@jffng jffng left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👏 This is an interesting idea!

What it gets around is the concept that block templates and template parts are only intended for re-usable parts of the site (i.e. not for demo content). Previously I had tried populating starter content with block templates, even though this mixed the idea of template and content in a potentially confusing way. In my opinion, explicitly having a block-starter-content folder helps keep the distinction clear conceptually.

I can't comment on the file_get_contents method or the robustness of starter content as a bulletproof mechanism to populate a fresh site (I did run into some starter content issues when I placed the demo content for TwentyTwenty). I might try stress testing this by including many posts and large files.

@jffng
Copy link
Collaborator

jffng commented Oct 22, 2020

@kjellr shall we close this? Seems like content like this, if at all, could ship with a pattern.

@kjellr
Copy link
Collaborator Author

kjellr commented Oct 22, 2020

Yeah, sounds good to me. 👍

@kjellr kjellr closed this Oct 22, 2020
@kjellr kjellr deleted the try/starter-content-template branch October 22, 2020 19:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants