mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
Adds support for og:locale
This commit is contained in:
parent
169600dc2d
commit
22741d8a04
4 changed files with 26 additions and 1 deletions
11
README.md
11
README.md
|
|
@ -52,6 +52,7 @@ url(string $url)
|
|||
title(string $title)
|
||||
description(string $description)
|
||||
image(string $url)
|
||||
locale(string $locale)
|
||||
|
||||
twitterCreator(string $username)
|
||||
twitterSite(string $username)
|
||||
|
|
@ -158,6 +159,16 @@ If you wish to change the URL, call `seo()->url()`:
|
|||
seo()->url(route('products.show', $this->product));
|
||||
```
|
||||
|
||||
### Locale
|
||||
|
||||
To set the `og:locale` property:
|
||||
|
||||
```php
|
||||
seo()->locale('de_DE');
|
||||
```
|
||||
|
||||
Expected format is `language_TERRITORY`.
|
||||
|
||||
### Modifiers
|
||||
|
||||
You may want to modify certain values before they get inserted into the template. For example, you may want to suffix the meta `<title>` with `| ArchTech` when it has a non-default value.
|
||||
|
|
|
|||
|
|
@ -20,6 +20,8 @@
|
|||
|
||||
@if(seo('site')) <meta property="og:site_name" content="@seo('site')"> @endif
|
||||
|
||||
@if(seo('locale')) <meta property="og:locale" content="@seo('locale')" /> @endif
|
||||
|
||||
@if(seo('image')) <meta property="og:image" content="@seo('image')" /> @endif
|
||||
|
||||
@if(seo('url'))
|
||||
|
|
|
|||
|
|
@ -15,6 +15,7 @@ use Illuminate\Support\Str;
|
|||
* @method $this site(string $site = null, ...$args) Set the site name.
|
||||
* @method $this image(string $url = null, ...$args) Set the cover image.
|
||||
* @method $this type(string $type = null, ...$args) Set the page type.
|
||||
* @method $this locale(string $locale = null, ...$args) Set the page locale.
|
||||
* @method $this twitter(enabled $bool = true, ...$args) Enable the Twitter extension.
|
||||
* @method $this twitterCreator(string $username = null, ...$args) Set the Twitter author.
|
||||
* @method $this twitterSite(string $username = null, ...$args) Set the Twitter author.
|
||||
|
|
@ -56,7 +57,7 @@ class SEOManager
|
|||
protected function getKeys(): array
|
||||
{
|
||||
return collect([
|
||||
'site', 'title', 'image', 'description', 'url', 'type',
|
||||
'site', 'title', 'image', 'description', 'url', 'type', 'locale',
|
||||
'twitter.creator', 'twitter.site', 'twitter.title', 'twitter.image', 'twitter.description',
|
||||
])
|
||||
->merge(array_keys($this->defaults))
|
||||
|
|
|
|||
|
|
@ -146,3 +146,14 @@ test('type can be overridden using the type method', function () {
|
|||
->toContain('<meta property="og:type" content="foo" />') // overridden
|
||||
->not()->toContain('website');
|
||||
});
|
||||
|
||||
test('og:locale is not included by default', function () {
|
||||
expect(meta())
|
||||
->not()->toContain('og:locale');
|
||||
});
|
||||
|
||||
test('og:locale can be added to the template', function () {
|
||||
seo()->locale('de_DE');
|
||||
|
||||
expect(meta())->toContain('<meta property="og:locale" content="de_DE" />');
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue