SEO : add tombi mori plugin
This commit is contained in:
parent
df2843123f
commit
8f9e75126e
64 changed files with 3719 additions and 44 deletions
13
site/plugins/kirby-seo/snippets/head.php
Normal file
13
site/plugins/kirby-seo/snippets/head.php
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @var \Kirby\Cms\Page $page
|
||||
*/
|
||||
|
||||
use Kirby\Cms\Html;
|
||||
|
||||
$tags = $page->metadata()->snippetData();
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
echo Html::tag($tag['tag'], $tag['content'] ?? null, $tag['attributes'] ?? []) . PHP_EOL;
|
||||
}
|
||||
58
site/plugins/kirby-seo/snippets/robots.txt.php
Normal file
58
site/plugins/kirby-seo/snippets/robots.txt.php
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
use Kirby\Toolkit\A;
|
||||
|
||||
if ($content = option('tobimori.seo.robots.content')) {
|
||||
if (is_callable($content)) {
|
||||
$content = $content();
|
||||
}
|
||||
|
||||
if (is_array($content)) {
|
||||
$str = [];
|
||||
|
||||
foreach ($content as $ua => $data) {
|
||||
$str[] = 'User-agent: ' . $ua;
|
||||
foreach ($data as $type => $values) {
|
||||
foreach ($values as $value) {
|
||||
$str[] = $type . ': ' . $value;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$content = A::join($str, PHP_EOL);
|
||||
}
|
||||
|
||||
echo $content;
|
||||
} else {
|
||||
// output default
|
||||
echo "User-agent: *\n";
|
||||
|
||||
$index = option('tobimori.seo.robots.index');
|
||||
if (is_callable($index)) {
|
||||
$index = $index();
|
||||
}
|
||||
|
||||
if ($index) {
|
||||
echo 'Allow: /';
|
||||
echo "\nDisallow: /panel";
|
||||
} else {
|
||||
echo 'Disallow: /';
|
||||
}
|
||||
}
|
||||
|
||||
if (($sitemap = option('tobimori.seo.robots.sitemap')) || ($sitemapModule = option('tobimori.seo.sitemap.active'))) {
|
||||
// Allow closure to be used
|
||||
if (is_callable($sitemap)) {
|
||||
$sitemap = $sitemap();
|
||||
}
|
||||
|
||||
// Use default sitemap if none is set
|
||||
if (!$sitemap && $sitemapModule) {
|
||||
$sitemap = site()->canonicalFor('/sitemap.xml');
|
||||
}
|
||||
|
||||
// Check again, so falsy values can't be used
|
||||
if ($sitemap) {
|
||||
echo "\n\nSitemap: {$sitemap}";
|
||||
}
|
||||
}
|
||||
8
site/plugins/kirby-seo/snippets/schemas.php
Normal file
8
site/plugins/kirby-seo/snippets/schemas.php
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<?php
|
||||
|
||||
$siteSchema ??= true;
|
||||
$pageSchema ??= true;
|
||||
|
||||
foreach (array_merge($siteSchema ? $site->schemas() : [], $pageSchema ? $page->schemas() : []) as $schema) {
|
||||
echo $schema;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue