Comments (7)
merged
from grav-plugin-shortcode-core.
I'm not very familiar with pull requests, so i'll attach some code that allows to use the new v5 font family classes fab, fal, fas and far:
if($icon) {
$fa_class = 'fa';
$extras = explode(',', $sc->getParameter('extras', ''));
foreach($extras as $extra) {
if(!empty($extra)) {
if(in_array($extra, array('fab', 'fal', 'fas', 'far'))) {
$fa_class = $extra;
continue;
}
if(!Utils::startsWith($extra, 'fa-')) {
$extra = 'fa-' . $extra;
}
$icon .= ' ' . $extra;
}
}
$output = '<i class="' . $fa_class . ' ' . $icon . '">' . $str . '</i>';
return $output;
}
Replace this into File shortcodes/FontAwesomeShortcode.php at line 25.
For testing purposes i have added the CDN version of Font Awesome:
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
This allows e.g. a spinning Grav icon with the Shortcode [fa icon=fa-grav extras=fab,fa-spin /]
from grav-plugin-shortcode-core.
I would maybe make your own, because i've found FA5 to not be 100% compatible with FA4
from grav-plugin-shortcode-core.
Great! Thank You! :D
from grav-plugin-shortcode-core.
I just realized that with the latest 4.0 version of shortcode-core, it probably won't work on Grav 1.5, but it will with 1.6-RC.4. As it depends on the new 'deferred' block functionality for adding assets to work.
I am going to add the deferred extension to 1.5, but it does require a minor fix in the theme to take advantage of it.
{% block assets deferred %}
{{ assets.css()|raw }}
{{ assets.js()|raw }}
{% endblock %}
from grav-plugin-shortcode-core.
So if you enable FA5, you then have to manually update the "Fontawesome URL" setting to something like so: //use.fontawesome.com/releases/v5.8.0/css/all.css
?
Just thinking this may cause confusion for some users if that's the case. But not sure if there is an easy fix?
from grav-plugin-shortcode-core.
it's a bit complicated, the logic i had before to get the assets and add them before the twig rendered, was actually breaking a number of plugins, and also modular forms.
I have a better way to do it using the deferred block capability, and ive added this to Grav 1.5 and i will release this very soon, but will require a change in the theme as outlined above.
from grav-plugin-shortcode-core.
Related Issues (20)
- CSS of shortcodes not loaded with twig, calling with markdown|shortcodes filter HOT 1
- Shortcode update creating copies of itself HOT 3
- Unexpected error message when updating v5.0.4 to v.5.0.5 HOT 6
- Shortcodes fail to render HOT 2
- Shortcodes don't work correctly with enabled Markdown Extra
- Accessing 'page' throws 404 error HOT 1
- Fontawesome icons are not displayed HOT 4
- Update Readme HOT 1
- Support 'subject' argument for safe-email shortcode
- Nested shortcodes broken in flex objects content HOT 5
- Unclear description of admin_pages_only option
- Twig variables not rendering inside html tags HOT 1
- Can't add assets after update HOT 4
- not possible to load JS assets in bottom group HOT 1
- Question: Autocomplete in Shortcode possible? HOT 1
- RegularParser fails with memory exhausted errors
- Shortcodes refer to wrong subpage when used in loop. HOT 3
- Shortcodes of subpages do not refer to the correct subpage.
- Assets not loaded when using shortcode only in Twig HOT 11
- Album icon shortcode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from grav-plugin-shortcode-core.