Skip to content

Commit

Permalink
Fix og:title no with full title bug
Browse files Browse the repository at this point in the history
  • Loading branch information
ycs77 committed Jul 15, 2023
1 parent 22e6ed7 commit 51a8ebc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/HeadManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function ogUrl(string $url = null)

public function ogTitle(string $title = null)
{
if ($title = $title ?? $this->title) {
if ($title = $title ?? $this->fullTitle) {
$this->tag('<meta property="og:title" content="%s">', e($title));
}

Expand Down
16 changes: 16 additions & 0 deletions tests/HeadManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,22 @@
]);
});

test('can add og:title with full title', function () {
$head = new HeadManager();

$head
->titleTemplate('%s - My website')
->title('Page title')
->ogTitle();

$elements = $head->getElements();

expect($elements)->toBe([
'<title>Page title - My website</title>',
'<meta property="og:title" content="Page title - My website">',
]);
});

test('can add title and custom og:title', function () {
$head = new HeadManager();

Expand Down

0 comments on commit 51a8ebc

Please sign in to comment.