Skip to content

Laravel component to get social share buttons for your website

License

Notifications You must be signed in to change notification settings

syvbyen/laravel-social-share

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔗 Laravel Social Share 🔗

This package will make social share links to the most popular platforms (you can remove the ones you don't want in the config). With links to share the page they are currently on. Icons are using Font Awesome by default, but you can change this in the config.

Table of Contents

Installation

You may use composer to install this package to your Laravel project

composer require syvbyen/laravel-social-share

Usage

To use it all you have to do is including the component in your view.

<x-social-share>

For Laravel versions without components, you can use the directive instead.

@socialshare

Configuration

/*
|--------------------------------------------------------------------------
| Shareables
|--------------------------------------------------------------------------
|
| These are the different types of shareables. If you can call them
| that. If you remove one of these they will not show up in your
| view anymore. Also, the icon refers to fontawesome classes
|
*/
'shareables' => [
    'facebook' => [
        'icon' => 'fab fa-facebook-f',
    ],
    'twitter' => [
        'icon' => 'fab fa-twitter',
    ],
    'linkedin' => [
        'icon' => 'fab fa-linkedin-in'
    ],
    'email' => [
        'icon' => 'fas fa-envelope'
    ],
    /* 
    'pinterest' => [
        'icon' => 'fab fa-pinterest',
    ]
    */
]

You can publish the config file of the package.

php artisan vendor:publish --provider="syvbyen\SocialShare\SocialShareServiceProvider" --tag=config

View

You are more than welcome to publish the view file and make it your own. This is how it looks right now.

<div class="social-share__wrapper">

    <p class="social-share__tagline">@lang('social-share::social-share.share')</p>

    @foreach($shareables as $shareable)

        <a href="{{ $shareable->href }}" class="social-share__link" rel="noreferrer" target="_blank">

                @isset($shareable->icon)

                    <i class="social-share__icon {{ $shareable->icon }}"></i>

                @endisset

            <span class="social-share__name">{{ $shareable->name }}</span>

        </a>

    @endforeach

</div>

You can f.ex change the $shareable->icon to an image source in the config and use an <img> tag instead. You can publish the view file like so:

php artisan vendor:publish --provider="syvbyen\SocialShare\SocialShareServiceProvider" --tag=view

Localization file

You can publish the language file of the package.

php artisan vendor:publish --provider="syvbyen\SocialShare\SocialShareServiceProvider" --tag=lang

Todo

  • Add copy to clipboard button
  • Design and make CSS
  • Give option to set the URL manually (if you want to share another page than the on you're on)

License

Social Share is open-source software licensed under the MIT license

About

Laravel component to get social share buttons for your website

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published