Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
runxel committed Jan 7, 2020
1 parent 24bf796 commit 441f1d5
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
16 changes: 16 additions & 0 deletions index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php
/**
* Kirby3 plugin to gain easyaccess to `simple-icons` in Kirbytext.
*
* @version 1.0.0
* @author Lucas Becker <runxel>
* @copyright Lucas Becker <runxel>
* @link https://github.com/runxel/kirby3-simpleicons
* @license MIT
*/

Kirby::plugin('runxel/kirby-simpleicons', [
'tags' => [
'icon' => require_once __DIR__ . '/tags/icon.php'
]
]);
28 changes: 28 additions & 0 deletions tags/icon.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php
# site/plugins/kirby-simpleicons/tags/icon.php

return array(
// passed options
'attr' => [
'class'
],
'html' => function($tag) {

// get options
$brand = $tag->icon;
$cls = $tag->class;

$icon_string = 'vendor/simple-icons/simple-icons/icons/' . $brand . '.svg';
$icon_svg = file_get_contents($icon_string)

/* https://getkirby.com/docs/reference/tools/html/tag
if HTML code is passed into Html::tag is must be wrappend in an array:
*/
$html = Html::tag('span', [$icon_svg], [
'class' => $icons
]);

return $html;
// <span class="cls"><svg … /></span>
}
);

0 comments on commit 441f1d5

Please sign in to comment.