I am trying to make a contextual component that can provide a default header when one is not passed in the yielded block. Normally, I could use the has-block helper to tell if a component has block content but this component will always have block content. I think what I need is a way to tell if the yielded component has block content. For example:
<header>
<h1>My Default Header</h1>
</header>
<section>
</section>
<footer>
</footer>
I only want the default header to show when the yielded "header" section is empty. I could create a header component which then could use the has-block like so:
<header>
</header>
...
<h1>My Default</h1>
Functionally I think this will work but the only purpose of the "my-header" component would be for this "panel" component and seems wasteful. Open to ideas. Thanks!
Aucun commentaire:
Enregistrer un commentaire