mirror of
https://github.com/archtechx/laravel-seo.git
synced 2025-12-12 01:44:03 +00:00
Support extra tags
This commit is contained in:
parent
21452f538b
commit
007a555d57
3 changed files with 41 additions and 0 deletions
|
|
@ -5,6 +5,10 @@
|
||||||
@if(seo('description')) <meta property="og:description" content="@seo('description')" /> @endif
|
@if(seo('description')) <meta property="og:description" content="@seo('description')" /> @endif
|
||||||
@if(seo('image')) <meta property="og:image" content="@seo('image')" /> @endif
|
@if(seo('image')) <meta property="og:image" content="@seo('image')" /> @endif
|
||||||
|
|
||||||
|
@foreach(seo()->tags() as $tag)
|
||||||
|
{!! $tag !!}
|
||||||
|
@endforeach
|
||||||
|
|
||||||
@foreach(seo()->extensions() as $extension)
|
@foreach(seo()->extensions() as $extension)
|
||||||
<x-dynamic-component :component="$extension" />
|
<x-dynamic-component :component="$extension" />
|
||||||
@endforeach
|
@endforeach
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,9 @@ class SEOManager
|
||||||
/** Metadata for additional features. */
|
/** Metadata for additional features. */
|
||||||
protected array $meta = [];
|
protected array $meta = [];
|
||||||
|
|
||||||
|
/** Extra head tags. */
|
||||||
|
protected array $tags = [];
|
||||||
|
|
||||||
/** Get all used values. */
|
/** Get all used values. */
|
||||||
public function all(): array
|
public function all(): array
|
||||||
{
|
{
|
||||||
|
|
@ -169,6 +172,28 @@ class SEOManager
|
||||||
return $this->set('image', "https://s.useflipp.com/{$template}.png?s={$signature}&v={$query}");
|
return $this->set('image', "https://s.useflipp.com/{$template}.png?s={$signature}&v={$query}");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Get all extra head tags. */
|
||||||
|
public function tags(): array
|
||||||
|
{
|
||||||
|
return $this->tags;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add a head tag. */
|
||||||
|
public function rawTag(string $tag): static
|
||||||
|
{
|
||||||
|
$this->tags[] = $tag;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Add a meta tag. */
|
||||||
|
public function tag(string $property, string $content): static
|
||||||
|
{
|
||||||
|
$this->rawTag("<meta property\"{$property}\" content=\"{$content}\" />");
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get or set metadata.
|
* Get or set metadata.
|
||||||
* @param string|array $key The key or key-value pair being set.
|
* @param string|array $key The key or key-value pair being set.
|
||||||
|
|
|
||||||
|
|
@ -82,3 +82,15 @@ test('thunks can be used as defaults', function () {
|
||||||
test('setting the defaults returns the manager instance', function () {
|
test('setting the defaults returns the manager instance', function () {
|
||||||
expect(seo()->title(default: 'foo'))->toBeInstanceOf(SEOManager::class);
|
expect(seo()->title(default: 'foo'))->toBeInstanceOf(SEOManager::class);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('meta tags can be added to the template', function () {
|
||||||
|
seo()->tag('fb:image', 'foo');
|
||||||
|
|
||||||
|
expect(meta())->toContain('<meta property="fb:image" content="foo" />');
|
||||||
|
});
|
||||||
|
|
||||||
|
test('raw tags can be added to the template', function () {
|
||||||
|
seo()->rawTag('<meta foo bar>');
|
||||||
|
|
||||||
|
expect(meta())->toContain('<meta foo bar>');
|
||||||
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue