eusonlito / laravel-meta Goto Github PK
View Code? Open in Web Editor NEWHTML Meta Tags management package available for for Laravel >= 5 (Including 10)
License: MIT License
HTML Meta Tags management package available for for Laravel >= 5 (Including 10)
License: MIT License
Hello! Thank you for this library. I just have a bit of issue. I'm already handling the <title>
tag myself so it would be great if this library didn't set it separately if I use:
Meta::title('Some title');
All I want is the meta title tag:
<meta name="title" content="Some title" />
<meta property="og:title" content="Some title" />
<meta name="twitter:title" content="Some title" />
Currently it's also rendering the title tag:
<title>Some title</title>
in the document
app/Http/Controllers/Controller.php
<?php namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Meta;
abstract class Controller extends BaseController
{
use DispatchesCommands, ValidatesRequests;
public function __construct()
{
# Default title
Meta::title('This is default page title to complete section title');
# Default robots
Meta::set('robots', 'index,follow');
}
}
should I replace my current Controller.php
with this I am using laravel 5.2
and when I used this DispatchesCommands
Got
Trait 'Illuminate\Foundation\Bus\DispatchesCommands' not found
here is my complete Controller.php file and what I try
<?php
namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesResources;
use Illuminate\Foundation\Bus\DispatchesCommands;
use Meta;
class Controller extends BaseController
{
use AuthorizesRequests, AuthorizesResources, DispatchesJobs, ValidatesRequests;
use DispatchesCommands, ValidatesRequests;
public function __construct()
{
# Default title
Meta::title('This is default page title to complete section title');
# Default robots
Meta::set('robots', 'index,follow');
}
}
Hello!
Currently this package does not let detect facade target with Laravel Idea Plugin, because it just returns an arbitrary string instead of FQCN.
Would you consider following?
use Illuminate\Support\Facades\Facade;
class Meta extends Facade
{
protected static function getFacadeAccessor(): string
{
return \Eusonlito\LaravelMeta\Meta::class;
}
}
$this->app->singleton(Eusonlito\LaravelMeta\Meta::class, function () {
return new Meta(config('meta'));
});
end result is the same, cause this string is really not used for anything else than binding!
Hi,
Something strange with some utf-8 characters (I'm french) :
In fact, with "é" no problem but with "à", I've got "�"...
Any idea ?
Thanks!
hello, i am using utf-8 text to set value for title, description but i can't set value,
when i try set value to title, title can't display in browser
Meta::set('title', 'Tổng Hợp Tài Liệu Tiếng Nhật');
the result: can't display title.
How to stop the "Title" - appname format
Hi, I can't find any information about laravel version support, could you update to Laravel 8 and add dependencies to coposer.json?
Hello!
In Meta.php tagString()s behaviour is rather irrational: it generates 1 property tag when called from tagMetaProperty() but two tags, 1 property and 1 name, when called from tagMetaName().
It's both confusing and inflexible – what if user ONLY wants to add a meta name tag? Moreover, why is tagMetaName() called so if it inserts both name and property?
You should either rename the function or remove lines 235-236 ;-)
PLease add meta tags for twitter as well
I'm facing a problem when I inject the \Eusonlito\LaravelMeta\Meta
instance in my controller and then trying to get the tags in my view (with the Facade).
Here's a basic example:
Route::get('/', function (\Eusonlito\LaravelMeta\Meta $meta) {
$meta->set('title', 'Hello world');
dd(Meta::get('title'));
});
As I expect this bit of code to dump 'Hello world', it actually dumps 'null'. It seems that the instance returned by the Meta Facade is not the same as the one retrieved by the injection mecanism.
When looking at the MetaServiceProvider
, I first thought it requires to define an alias like this:
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
$this->app->singleton(Meta::class, function () {
return new Meta(config('meta'));
});
$this->app->alias(Meta::class, 'meta');
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [Meta::class, 'meta'];
}
But still not working.
Anyone else facing this issue ?
I am using laravel mix for my images which generates a relative path to the image via mix().
I'm finding myself repetitively prepending env('APP_URL')
in my meta::set('image','...')
so my images are absolutely pathed.
Could we have a option in config.php for 'image_base' => env('APP_URL')
to permit this functionality?
Thank you =)
Would be nice to have content set from database identified by slug or route
When not setting in the current Controller, it falls back to the config ignoring app\Http\Controllers\Controller::__construct .
Meta::set is not working for image
.
>>> Meta::set('image', 'http://localhost:8000/media/1-17.png')
=> ""
>>> Meta::get('image')
=> []
hi i want to know this package works with laravel 5.3?
Package Auto-Discovery significantly simplifies installation of Laravel packages. It would be great to have this feature implemented in laravel-Meta.
If you don't mind, I will provide a PR in a few minutes.
Looks like you might be missing a piece in your readme when dealing with setting default values in Controller.php -
Your HomeController.php needs a
public function __construct()
{
parent::__construct();
}
Otherwise your defaults don't get called
can i generate a keywords tag without a facebook OG Tag too? because open graph does not have "og:keywords"
Here's my use case -
LinkedIn only seems to grab the first og:image
I set a default "catch all" image in Controller.php
I set more specific images in controllers that extend Controller.php
I output images with {!! Meta::tag('image') !!}
Is there any way to -
Unset a previously set image? Or override an image? Or reverse the order of the images?
The type hinting used in the Meta::__construct gets the package incompatible with barryvdh/laravel-ide-helper, which passes a null value to the constructor and throw an error.
php artisan ide-helper:generate
[Symfony\Component\Debug\Exception\FatalThrowableError]
Type error: Argument 1 passed to Eusonlito\LaravelMeta\Meta::__construct()
must be of the type array, null given, called in D:\Progetti\studioelps.com
\StudioElps\vendor\eusonlito\laravel-meta\src\Eusonlito\LaravelMeta\MetaSer
viceProvider.php on line 35
strlen should be mb_strlen.
substr should be mb_substr.
To avoid breaking utf-8 characters.
When trying to add twitter cards:
{!! Meta::tag('card') !!}
I am seeing the following rendered:
<meta name="card" content="Summary" />
<meta name="twitter:card" content="Summary" />
...when all I want is:
<meta name="twitter:card" content="Summary" />
I see some granularity was added in 2.0 but I don't see a way to call Meta::tagTwitterCard
or similar.
Thank you.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.