feat: intégration plugin Kirby SEO
All checks were successful
Deploy / Deploy to Production (push) Successful in 22s
All checks were successful
Deploy / Deploy to Production (push) Successful in 22s
- Ajout de tobimori/kirby-seo via Composer
- snippet('seo/head') dans header.php (remplace les meta manuels)
- snippet('seo/schemas') dans footer.php pour JSON-LD
- Onglet SEO ajouté dans site.yml et tous les blueprints de pages
- Configuration SEO dans config.php (sitemap, robots, canonicalBase TODO)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
baab2fb3a1
commit
58c31ea391
133 changed files with 9201 additions and 253 deletions
86
site/plugins/kirby-seo/config/hooks.php
Normal file
86
site/plugins/kirby-seo/config/hooks.php
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Cms\File;
|
||||
use Kirby\Cms\Page;
|
||||
use Kirby\Toolkit\A;
|
||||
use Kirby\Toolkit\Str;
|
||||
use tobimori\Seo\Field\AltTextField;
|
||||
use tobimori\Seo\Seo;
|
||||
|
||||
return [
|
||||
'system.loadPlugins:after' => function () {
|
||||
if (class_exists('tobimori\Queues\Queues')) {
|
||||
\tobimori\Queues\Queues::register(\tobimori\Seo\Jobs\GenerateAltTextJob::class);
|
||||
}
|
||||
},
|
||||
'file.create:after' => function (File $file) {
|
||||
if ($file->type() !== 'image') {
|
||||
return;
|
||||
}
|
||||
|
||||
if (class_exists('tobimori\Queues\Queues')) {
|
||||
\tobimori\Queues\Queues::push('seo:generate-alt-text', [
|
||||
'fileId' => $file->id(),
|
||||
]);
|
||||
|
||||
return $file;
|
||||
}
|
||||
|
||||
return AltTextField::generateForFile($file);
|
||||
},
|
||||
'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