Skip to content

KaqazStudio/laravel-interlink

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Quality Score Total Downloads

WORK IN PROGRESS, some functionalities may be changed in the future.

Add internal link to your published assets.

Installation

You can install the package via composer:

composer require kaqazstudio/laravel-interlink

Manual Registration

If autodiscovery doesn't work, register the package in your project manually.

■ Add this line to config/app.php > providers array

KaqazStudio\LaravelInterlink\ServiceProvider\LaravelInterlinkServiceProvider::class

■ Then add the line below to config/app.php > aliases array

'LaravelInterlink' => KaqazStudio\LaravelInterlink\Facade\LaravelInterlinkFacade::class

Use with Facade

Initialize Interlink

LaravelInterlink::single();

Use without Facade

Initialize Interlink without facade

LaravelInterlink::access();

Laravel Interlink are available on chains! :)

Methods

Method Required Type Default Description
init true chain Fire the engine
setKeyword true string null Set target keyword
setTitle false string keyword Replace with the keyword
setLink true string null Set internal link url
rawLink false bool false Set link url to raw format
setCount false int infinite Count of link replacement
setPosts true array null Set posts collection
column true string null Set content column
markdown false bool false MarkDown format for links
blank false bool false Set links target to _blank
noFollow false bool false Set links rel to nofollow
setCustomAttributes false string null Set custom html attributes for a tag
process true chain Process link internalization
getUpdatedPosts false chain Get updated posts as a collection
updatePosts false chain Do update method on all posts

Example

For example, you want to refer all first AirPods words to /apple-airpods in all of your published Blog posts.

LaravelInterlink::single()
                ->init()                     // Warm engine
                ->setKeyword('AirPods')      // Target Keyword
                ->setLink('/apple-airpods')  // Target url
                ->setCount(1)                // For first word
                ->setPosts(BlogPost::all())  // Get all blog posts
                ->setColumn('body')          // Set `body` column for content target
                ->process()                  // Process internalization
                ->updatePosts();             // Run update on posts!

Also, you can get all updated contents as a collection!

So, you MOST use getUpdatedPosts() INSTEAD OF updatePosts()

Use customized links

When you need to use your own format for link you can easily do like this

LaravelInterlink::single()
                ...
                ->setLink('<a href="own.com">Custom-Link</a>')  // Your custom format
                ->rawLink()                                     // Raw link format [+]
                ...

Or, Maybe you to add custom html attributes to default link format - "Default a tag"

LaravelInterlink::single()
                ...
                ->setCustomAttributes('custom-data="Hello"')  // Raw link format [+]
                ...

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.