Render the components as partials.
See https://github.com/usebedrock/bedrock/issues/391 for a discussion.
This is currently only done in the build step, and not for the the live development server.
Let me know if you prefer to have the code for the live development server in the same PR; I guess I can have a look at it too.
And maybe you'd like an example use case with htmx before merging ? Or small PRs like these are fine ?
(Btw this is extracted and modified form the https://github.com/thusc/bedrock/tree/cli branch you saw before, but maybe this one will take more time and I prefer to separate different features.)
Here is an example file:
$ cat dist/partials/cc-example/01-my-component.html
<div class="example">
<p>This is an example component.</p>
</div>
Edit: here is the same example on the automated Vercel deployment: https://bedrock-git-fork-thusc-render-partials-monocompany.vercel.app/partials/cc-example/01-my-component.html
This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployment, click below or on the icon next to each commit.
🔍 Inspect: https://vercel.com/monocompany/bedrock/mKvequ1nraX62q72pesRr5S7i92c
✅ Preview: https://bedrock-git-fork-thusc-render-partials-monocompany.vercel.app
Very cool! 😍
To merge PR the functionality I would like it to be behind a flag.
What if the logic of putting it behind the styleguide: false config option at this point?
https://github.com/usebedrock/bedrock/pull/399/files#diff-25789e3ba4c2adf4a68996260eb693a441b4a834c38b76167a120f0b51b969f7R52-R57
If you could implement a config flag that enables this option separately (e.g. renderPartials), I can add it to the docs.
Then we can default it to false. This way it can continue to be developed and it's not in anyone's way.
Done.
(It was actually not behind de styleguide flag: it was built whether or not that flag was set. In my mind, the partials might be used in the regular prototype, outside the styleguide.)
(When you change the doc, note that the doc talks about config.js instead of default-config.js at the top of that page.)
@Wolfr Can you put this PR on hold, until https://github.com/usebedrock/bedrock/pull/404 and the CLI things are merged ? it will be cleaner to first have those before adding a new feature.
@thusc OK, noted!