This is a package that converts keywords into links.
| Package Version | Requirement | Version |
|---|---|---|
| 1.x.x | Laravel | 10.x or 11.x |
| 1.x.x | Nova | 4.x |
| dev-beta-laravel-12 | Laravel | 12.x |
| dev-beta-laravel-12 | Nova | 5.x |
You can install the package via composer:
composer install the-3labs-team/keyword-linkerYou 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',
],
'query_tracking' => [
'enabled' => false,
'query_string' => 'tracking=kwlinker',
],
];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> contentUse 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 testPlease 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.