Create KirbyTag.
This commit is contained in:
16
README.md
16
README.md
@@ -2,6 +2,22 @@
|
|||||||
|
|
||||||
A plugin for [Kirby](https://getkirby.com) to load the [Font Awesome](https://fontawesome.com) assets via the `getAssets()` hook of the [Kirby Library](https://git.hobbyhome.net/HobbyHome/kirby-library) plugin.
|
A plugin for [Kirby](https://getkirby.com) to load the [Font Awesome](https://fontawesome.com) assets via the `getAssets()` hook of the [Kirby Library](https://git.hobbyhome.net/HobbyHome/kirby-library) plugin.
|
||||||
|
|
||||||
|
## KirbyTag
|
||||||
|
|
||||||
|
```
|
||||||
|
<?= kirbytag("fa", "icon", ["fastyle" => "regular"]) ?>
|
||||||
|
|
||||||
|
<i class="fa-classic fa-regular fa-icon"></i>
|
||||||
|
```
|
||||||
|
|
||||||
|
Supports the following attributes:
|
||||||
|
|
||||||
|
- **style** - Inline CSS style to apply to the icon.
|
||||||
|
- **class** - CSS classes to apply to the icon.
|
||||||
|
- **family** - The Font Awesome family of icon.
|
||||||
|
- **fastyle** - The Font Awesome style of icon.
|
||||||
|
- **title** - A title to add to the icon. Useful for tooltips.
|
||||||
|
|
||||||
# License
|
# License
|
||||||
|
|
||||||
Kirby Font Awesome is Copyright 2026, [Dreytac](mailto:dreytac@hobbyhome.net).
|
Kirby Font Awesome is Copyright 2026, [Dreytac](mailto:dreytac@hobbyhome.net).
|
||||||
|
|||||||
36
index.php
36
index.php
@@ -15,6 +15,8 @@ Kirby::plugin(
|
|||||||
name: "hobbyhome/fontawesome",
|
name: "hobbyhome/fontawesome",
|
||||||
extends: [
|
extends: [
|
||||||
"options" => [
|
"options" => [
|
||||||
|
"defaultFamily" => "classic",
|
||||||
|
"defaultStyle" => "solid",
|
||||||
"assets" => [
|
"assets" => [
|
||||||
"css" => [
|
"css" => [
|
||||||
150 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/fontawesome/css/fontawesome" . r(!option("debug"), ".min") . ".css", true),
|
150 => Url::path(kirby()->url("media") . "/plugins/hobbyhome/fontawesome/css/fontawesome" . r(!option("debug"), ".min") . ".css", true),
|
||||||
@@ -43,6 +45,40 @@ Kirby::plugin(
|
|||||||
return $files;
|
return $files;
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
|
"tags" => [
|
||||||
|
"fa" => [
|
||||||
|
"attr" => [
|
||||||
|
"style",
|
||||||
|
"class",
|
||||||
|
"family",
|
||||||
|
"fastyle",
|
||||||
|
"title",
|
||||||
|
],
|
||||||
|
"html" => function ($tag) {
|
||||||
|
$html = "";
|
||||||
|
|
||||||
|
if ($tag->style) {
|
||||||
|
$html .= "<span style=\"{$tag->style}\">";
|
||||||
|
}
|
||||||
|
|
||||||
|
$html .= "<i" .
|
||||||
|
" class=\"" .
|
||||||
|
r($tag->class, $tag->class . " ") .
|
||||||
|
"fa-" . r($tag->family, $tag->family, option("hobbyhome.fontawesome.defaultFamily")) . " " .
|
||||||
|
"fa-" . r($tag->fastyle, $tag->fastyle, option("hobbyhome.fontawesome.defaultStyle")) . " " .
|
||||||
|
"fa-" . $tag->value .
|
||||||
|
"\"" .
|
||||||
|
r($tag->title, " title=\"{$tag->title}\"") .
|
||||||
|
"></i>";
|
||||||
|
|
||||||
|
if ($tag->style) {
|
||||||
|
$html .= "</span>";
|
||||||
|
}
|
||||||
|
|
||||||
|
return $html;
|
||||||
|
},
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
info: [
|
info: [
|
||||||
"authors" => [[
|
"authors" => [[
|
||||||
|
|||||||
Reference in New Issue
Block a user