Skip to content

Commit

Permalink
feat: add canonical tag to default seo markup
Browse files Browse the repository at this point in the history
  • Loading branch information
BernhardBaumrock committed Apr 24, 2024
1 parent 71c6e41 commit 5d6de01
Showing 1 changed file with 16 additions and 6 deletions.
22 changes: 16 additions & 6 deletions Seo.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ public function __construct()

/** ##### public API ##### */

public function canonical(callable $callback): self
{
return $this;
}

/**
* Shortcut to set description and og:description at once
*/
Expand Down Expand Up @@ -357,14 +362,14 @@ public function ___setupDefaults()
$n = "\n ";
return
// all browsers
"<link rel='icon' type='image/png' sizes='32x32' href={$png->size(32, 32,$opt)->url}>"
. "$n<link rel='icon' type='image/png' sizes='16x16' href={$png->size(16, 16,$opt)->url}>"
"<link rel='icon' type='image/png' sizes='32x32' href='{$png->size(32, 32,$opt)->url}'>"
. "$n<link rel='icon' type='image/png' sizes='16x16' href='{$png->size(16, 16,$opt)->url}'>"
// google and android
. "$n<link rel='icon' type='image/png' sizes='48x48' href={$png->size(48, 48,$opt)->url}>"
. "$n<link rel='icon' type='image/png' sizes='192x192' href={$png->size(192, 192,$opt)->url}>"
. "$n<link rel='icon' type='image/png' sizes='48x48' href='{$png->size(48, 48,$opt)->url}'>"
. "$n<link rel='icon' type='image/png' sizes='192x192' href='{$png->size(192, 192,$opt)->url}'>"
// apple iphone and ipad
. "$n<link rel='apple-touch-icon' type='image/png' sizes='167x167' href={$png->size(167, 167,$opt)->url}>"
. "$n<link rel='apple-touch-icon' type='image/png' sizes='180x180' href={$png->size(180, 180,$opt)->url}>";
. "$n<link rel='apple-touch-icon' type='image/png' sizes='167x167' href='{$png->size(167, 167,$opt)->url}'>"
. "$n<link rel='apple-touch-icon' type='image/png' sizes='180x180' href='{$png->size(180, 180,$opt)->url}'>";
});

// webmanifest
Expand All @@ -383,6 +388,11 @@ public function ___setupDefaults()
return $rf->manifest()->themeColor;
});
}

$this->setMarkup('canonical', '<link rel="canonical" href="{value}">');
$this->setValue('canonical', function (Page $page) {
return $page->httpUrl();
});
}

/**
Expand Down

0 comments on commit 5d6de01

Please sign in to comment.