Skip to content
This repository has been archived by the owner on Mar 19, 2023. It is now read-only.
/ metadata Public archive

This package allow you to simplify the process of adding meta tags to your HTML

Notifications You must be signed in to change notification settings

wearejust/metadata

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status

MetaData

This package allow you to simplify the process of adding meta tags to your HTML. It basically allows you to use a simple to use API.

Installlation

Laravel 5 integration

This package ships with a Laravel 5 Service Provider to simplify the process. Also a ViewComposer is registered automatically so that there always is a variable $metaData in the in the config specified views

app.php

'providers' => [
    ...
    ...
    Just\MetaData\Laravel\MetaDataServiceProvider::class,
]

'aliases' => [
    ...
    ...
    'MetaData'  => Just\MetaData\Laravel\Facades\MetaData::class,
]

You can publish the (default) config by fire the following command

php artisan vendor:publish --provider="Just\MetaData\Laravel\MetaDataServiceProvider"

Example

Route::get('/', function (Just\MetaData\MetaDataWrapper $manager) {
    ...
    $images = [];
    
    $manager->fromData('Title', 'Desription', $images);
    //OR
    $object = new SometingWithFollowingInterface(MetaDataInterface);
    $manager->fromInterface($object);

    // You may also use the Facade
    $object = MetaData::fromInterface($object);

    return view('welcome');
});

API of the $metaData object in view

    /**
     * @return string
     */
    public function getTitle();

    /**
     * @return string
     */
    public function getDescription();

    /**
     * @return array
     */
    public function getImages();

    /**
     * @return string
     */
    public function getBaseUrl();

    /**
     * @return string
     */
    public function getCurrentUrl();