I'm trying to extend one of my themes by adding custom components using modular pages. The issue I'm facing is that I can't load assets inside a module the same way I would in a regular page. Using:
{% do assets.addCss('theme://css/componentA.css') %}
{% do assets.addJs('theme://js/componentA.js', {group: 'bottom'}) %}
has no effect when placed inside a modular page template. Because of this, the only reliable option seems to be placing the CSS and JavaScript directly inside <style> and <script> blocks within the module file.
I remember reading that Grav has some limitations regarding asset loading in modular pages.
To keep my templates cleaner, I'm currently including partials that contain the CSS and JS:
{% include 'modular/partials/components/componentA/componentA-styles.html.twig' %}
{% include 'modular/partials/components/componentA/componentA-scripts.html.twig' %}
This works, but it feels like a workaround.
Is there a more efficient or recommended way to include CSS and JavaScript within a modular page module?