This is a package that converts keywords into links.
You can install the package via composer:
composer install the-3labs-team/keyword-linker
You can publish the config file with:
php artisan vendor:publish --tag=keyword-linker-config
This is the contents of the published config file:
return [
'limit-auto-keywords' => 5, // limit auto keywords to be linked
'whitelist' => [
'p',
'blockquote',
],
];
use The3LabsTeam\KeywordLinker\Facades\KeywordLinker;
$content = "This is a test content";
$keywords = [
'test' => 'https://example.com/test',
// Usage: 'keyword' => 'link'
];
echo KeywordLinker::parse($content, $keywords);
# output: This is a <a href="http://example.com/test">test</a> content
Use rel attribute to add nofollow to the link
$keywords = [
'test' => [
'link' => 'https://example.com/test',
'rel' => 'nofollow'
],
// Usage: 'keyword' => ['link' => 'link', 'rel' => 'nofollow']
];
Use target attribute to open the link in a new tab
$keywords = [
'test' => [
'link' => 'https://example.com/test',
'target' => '_blank'
],
// Usage: 'keyword' => ['link' => 'link', 'target' => '_blank']
];
composer test
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING for details.
Please review our security policy on how to report security vulnerabilities.
The MIT License (MIT). Please see License File for more information.