OleVik / grav-plugin-static-generator

Indexing and static generation of Page(s) for Grav.
MIT License
23 stars 1 forks source link

Assets not found when added dynamically #5

Closed SteveMcArthur closed 4 years ago

SteveMcArthur commented 4 years ago

The plugins cannot find assets when they are dynamicly added and throws an error.

I have a template where assets are added to an individual page when they are present in the page yaml header. Like this:

scripts: ["theme://js/script.js"] styles: ["theme://css/styles.css"]

In the template they are added like this:

 {% if page.header.scripts %}
    {% for script in page.header.scripts %}
         {% do assets.addJs(script) %}
    {% endfor %}
 {% endif %}

Looking into the Assets.php module I can see that the file path to the asset to be copied is appended with the theme location. Something like this: {{GRAV_ROOT}}{{THEME_LOCATION}}/js/script.js

However, when added dynamically the theme location part mysteriously disappears and the plugin look for the asset straight in at the Grav root. Like this: {{GRAV_ROOT}}/js/script.js And an error is thrown.

It's got me slightly baffled this one.

OleVik commented 4 years ago

I think this might be improved with the API-changes implemented for v2.0.0-beta.1.