chore: update kirby-seo plugin to v2.0.0-alpha.12
Update plugin from v1.1.2 to v2.0.0-alpha.12 for Kirby 5 compatibility. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
ff215de723
commit
04a14a7f1f
70 changed files with 6142 additions and 3 deletions
64
site/plugins/kirby-seo/config/hooks.php
Normal file
64
site/plugins/kirby-seo/config/hooks.php
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Toolkit\A;
|
||||
use Kirby\Toolkit\Str;
|
||||
use tobimori\Seo\Seo;
|
||||
|
||||
return [
|
||||
'page.update:after' => function (Page $newPage, Page $oldPage) {
|
||||
// only inject blueprint defaults if the seo tab is present
|
||||
if ($newPage->blueprint()->tab('seo')) {
|
||||
$updates = A::reduce(
|
||||
$newPage->kirby()->option('tobimori.seo.robots.types'),
|
||||
function ($carry, $robots) use ($newPage) {
|
||||
$upper = Str::ucfirst($robots);
|
||||
|
||||
if ($newPage->content()->get("robots{$upper}")->value() === '') {
|
||||
$carry["robots{$upper}"] = 'default';
|
||||
}
|
||||
|
||||
return $carry;
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
if (A::count($updates)) {
|
||||
$newPage = $newPage->update($updates, $newPage->kirby()->languageCode());
|
||||
}
|
||||
}
|
||||
|
||||
if (Seo::option('indexnow.enabled')) {
|
||||
$indexNow = new (Seo::option('components.indexnow'))($newPage);
|
||||
$indexNow->request();
|
||||
}
|
||||
|
||||
return $newPage;
|
||||
},
|
||||
'page.changeStatus:after' => function (Page $newPage, Page $oldPage) {
|
||||
if (Seo::option('indexnow.enabled')) {
|
||||
$indexNow = new (Seo::option('components.indexnow'))($newPage);
|
||||
$indexNow->request();
|
||||
}
|
||||
},
|
||||
'page.changeSlug:after' => function (Page $newPage, Page $oldPage) {
|
||||
if (Seo::option('indexnow.enabled')) {
|
||||
$indexNow = new (Seo::option('components.indexnow'))($newPage);
|
||||
$indexNow->request();
|
||||
}
|
||||
},
|
||||
'page.render:before' => function (string $contentType, array $data, Page $page) {
|
||||
if (!class_exists('Spatie\SchemaOrg\Schema')) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (option('tobimori.seo.generateSchema')) {
|
||||
$page->schema('WebSite')
|
||||
->url($page->metadata()->canonicalUrl())
|
||||
->copyrightYear(date('Y'))
|
||||
->description($page->metadata()->metaDescription())
|
||||
->name($page->metadata()->metaTitle())
|
||||
->headline($page->metadata()->title());
|
||||
}
|
||||
},
|
||||
];
|
||||
Loading…
Add table
Add a link
Reference in a new issue