SEO : add tombi mori plugin
This commit is contained in:
parent
df2843123f
commit
8f9e75126e
64 changed files with 3719 additions and 44 deletions
28
site/plugins/kirby-seo/config/siteMethods.php
Normal file
28
site/plugins/kirby-seo/config/siteMethods.php
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Http\Url;
|
||||
use Kirby\Toolkit\Str;
|
||||
use tobimori\Seo\SchemaSingleton;
|
||||
|
||||
return [
|
||||
'schema' => fn ($type) => SchemaSingleton::getInstance($type),
|
||||
'schemas' => fn () => SchemaSingleton::getInstances(),
|
||||
'lang' => fn () => Str::replace(option('tobimori.seo.default.lang')($this->homePage()), '_', '-'),
|
||||
'canonicalFor' => function (string $url) {
|
||||
$base = option('tobimori.seo.canonicalBase');
|
||||
if (is_callable($base)) {
|
||||
$base = $base($url);
|
||||
}
|
||||
|
||||
if ($base === null) {
|
||||
$base = $this->url(); // graceful fallback to site url
|
||||
}
|
||||
|
||||
if (Str::startsWith($url, $base)) {
|
||||
return $url;
|
||||
}
|
||||
|
||||
$path = Url::path($url);
|
||||
return url($base . '/' . $path);
|
||||
}
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue