Closed
Description
I use blade-ui-kit/blade-icons for my custom icons sets, and for social icons I've tried to use them too, but when I tried to put Blade Component syntax in the config/share-buttons.php
within templates
values - like so
// config/share-buttons.php
// ...
'twitter' => '<a href=":url" class="social-button:class":id:title:rel><x-buk-icon name="social-twitter" width="24" height="24"/></a>',
// ...
it just rendered nothing - because the whole string itself is not handled as a Blade template.
To achieve the intended I've done the following:
// resources/components/social-share-buttons.blade.php
@props([
'url' => '',
'title' => '',
'socials' => [
'twitter' => [],
],
])
@php
$renderer = ShareButtons::page($url, $title);
foreach ($socials as $name => $options) {
if (!is_string($name)) {
$renderer->{$options}();
} else {
$renderer->{$name}($options);
}
}
$rendered = Blade::render($renderer->render());
@endphp
{!! $rendered !!}
Then it processed the final string via Blade's render
and displayed the icon as I've wanted.
Cheers! Great lib!
Metadata
Metadata
Assignees
Labels
No labels