getgrav / grav

Modern, Crazy Fast, Ridiculously Easy and Amazingly Powerful Flat-File CMS powered by PHP, Markdown, Twig, and Symfony
https://getgrav.org
MIT License
14.55k stars 1.41k forks source link

Unwanted CSS #3390

Open studioraygun opened 3 years ago

studioraygun commented 3 years ago

I have a bare bones theme setup and am pulling in some CSS using:

{% do assets.addCss('theme://css/style.css') %}
{% block assets deferred %}
      {{ assets.css()|raw }}
 {% endblock %}

On inspecting the page I can see that my CSS is pulled in but so is notices.css, login.css and form-styles.css

I'm not sure at this stage if I need this, so want to remove them. I found out how to do this here: https://discourse.getgrav.org/t/admin-plugin-assets-being-used-on-the-site/10043 but that is via the admin panel. Seems a bit odd that I can't do this in code, perhaps in the YAML file? Is that possible?

Thanks

rhukster commented 3 years ago

those are all added by plugins. Most of those plugins have options to disable built-in CSS.

iainsgillis commented 2 years ago

Hey @studioraygun --

Following up on @rhukster's response, here's one way you might achieve this from the command line.

From the root of your Grav installation:

First, find the files you mentioned, do some crude awking to find the corresponding yaml configuration files for each of those plugins, and copy them to the ./user/config folder so your overrides persist across plugin updates.

find ./user/plugins/ -type f | \
grep -P '(login|form-styles|notices)\.css$' | \
awk -F/ '{print $1"/"$2"/"$3"/"$4"/"$4".yaml"}' | \
xargs cp -t ./user/config/

Then flick the default true values over to false for the built_in_css key in each of those newly copied files.

find ./user/config/ -type f | \
grep -P '(login|form|markdown-notices)\.yaml$' | \
xargs sed -E -i 's/(built_in_css: )true/\1false/g'

Alternatively, if you have yq installed, you could replace the last line with xargs -L1 yq e -i '.built_in_css = false'

Hope this helps. Cheers, .ig