Component metadata
Assets in a component can be more than CSS and JavaScript files; you may have icons or images too.
To print them in a component’s Twig file, you must know the path where the component folder is. SDC automatically injects into every component the componentMetadata
variable, which contains some information about the component itself:
Figure 11.4 – The output of dumping the componentMetadata variable
If you have an assets
folder in your component with an icon.png
file in it, you can print the icon using code like the following:
<img src="/{{ componentMetadata.path }}/assets/icon.png" />
Now that we have our set of components, we can expose them to Storybook.