SEO : add tombi mori plugin

This commit is contained in:
isUnknown 2025-05-13 09:03:14 +02:00
parent df2843123f
commit 8f9e75126e
64 changed files with 3719 additions and 44 deletions

View file

@ -0,0 +1,33 @@
type: group
fields:
metaHeadline:
label: meta-headline
type: headline
numbered: false
metaTitle:
label: title-overwrite
type: text
placeholder: '{{ page.title }}'
metaTemplate:
label: meta-title-template
type: text
help: meta-title-template-help
width: 2/3
placeholder: '{{ page.metadata.metaTemplate }}'
useTitleTemplate:
label: use-title-template
type: toggle
help: use-title-template-help
width: 1/3
default: true
text:
- "{{ t('use-title-template-no') }}"
- "{{ t('use-title-template-yes') }}"
metaDescription:
label: meta-description
type: textarea
help: meta-description-help
placeholder: '{{ page.metadata.metaDescription }}'
buttons: false
seoLine1:
type: line

View file

@ -0,0 +1,48 @@
type: group
fields:
ogHeadline:
label: og-headline
type: headline
numbered: false
help: global-og-headline-help
ogTemplate:
label: og-title-template
type: text
width: 2/3
help: meta-title-template-help
placeholder: '{{ page.metadata.ogTemplate }}'
useOgTemplate:
label: use-title-template
type: toggle
help: use-title-template-help
width: 1/3
default: true
text:
- "{{ t('use-title-template-no') }}"
- "{{ t('use-title-template-yes') }}"
ogDescription:
label: og-description
type: textarea
buttons: false
placeholder: '{{ page.metadata.ogDescription }}'
ogImage:
label: og-image
extends: seo/fields/og-image
empty: og-image-empty
twitterCardType:
label: twitter-card-type
width: 1/2
placeholder: "{{ t('default-select') }} {{ t(site.twitterCardType) }}"
type: select
options:
summary: "{{ t('summary') }}"
summary_large_image: "{{ t('summary_large_image') }}"
help: twitter-card-type-help
twitterAuthor:
label: twitter-author
width: 1/2
type: text
before: '@'
placeholder: '{{ page.metadata.twitterCreator }}'
seoLine2:
type: line

View file

@ -0,0 +1,31 @@
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\Str;
return function (App $kirby) {
$blueprint = [
'type' => 'files',
'multiple' => false,
'uploads' => [],
'query' => Str::contains($kirby->path(), '/site') && !Str::contains($kirby->path(), 'pages') ? 'site.images' : 'page.images' // small hack to get context for field using api path
];
if ($parent = option('tobimori.seo.files.parent')) {
$blueprint['uploads'] = [
'parent' => $parent
];
$blueprint['query'] = "{$parent}.images";
}
if ($template = option('tobimori.seo.files.template')) {
$blueprint['uploads'] = [
...$blueprint['uploads'],
'template' => $template
];
$blueprint['query'] = "{$blueprint['query']}.filterBy('template', '{$template}')";
}
return $blueprint;
};

View file

@ -0,0 +1,55 @@
<?php
use Kirby\Cms\App;
use Kirby\Toolkit\A;
use Kirby\Toolkit\Str;
use tobimori\Seo\Meta;
return function (App $kirby) {
if (!$kirby->option('tobimori.seo.robots.active') || !$kirby->option('tobimori.seo.robots.pageSettings')) {
return [
'type' => 'hidden'
];
}
$fields = [
'robotsHeadline' => [
'label' => 'robots',
'type' => 'headline',
'numbered' => false,
]
];
$page = Meta::currentPage();
foreach ($kirby->option('tobimori.seo.robots.types') as $robots) {
$upper = Str::ucfirst($robots);
$fields["robots{$upper}"] = [
'label' => "robots-{$robots}",
'type' => 'toggles',
'help' => "robots-{$robots}-help",
'width' => '1/2',
'default' => 'default',
'reset' => false,
'options' => [
'default' => $page ?
A::join([
t('default-select'),
$page->metadata()->get("robots{$upper}", ['fields'])->toBool() ? t('yes') : t('no')
], ' ')
: t('default-select'),
'true' => t('yes'),
'false' => t('no'),
]
];
}
$fields['seoLine3'] = [
'type' => 'line'
];
return [
'type' => 'group',
'fields' => $fields,
];
};

View file

@ -0,0 +1,49 @@
<?php
use Kirby\Cms\App;
return function (App $kirby) {
if (!$kirby->option('tobimori.seo.robots.active') || !$kirby->option('tobimori.seo.robots.pageSettings')) {
return [
'type' => 'hidden'
];
}
$fields = [
'robotsHeadline' => [
'label' => 'robots',
'type' => 'headline',
'numbered' => false,
]
];
foreach ($kirby->option('tobimori.seo.robots.types') as $robots) {
$index = $kirby->option('tobimori.seo.robots.index');
if (is_callable($index)) {
$index = $index();
}
$fields["robots{$robots}"] = [
'label' => "robots-{$robots}",
'type' => 'toggles',
'help' => "robots-{$robots}-help",
'width' => '1/2',
'default' => 'default',
'reset' => false,
'options' => [
'default' => t('default-select') . ' ' . ($index ? t('yes') : t('no')),
'true' => t('yes'),
'false' => t('no'),
]
];
}
$fields['seoLine3'] = [
'type' => 'line'
];
return [
'type' => 'group',
'fields' => $fields,
];
};

View file

@ -0,0 +1,30 @@
<?php
/**
* Social Media Accounts field
* Allows social media account list to be filled by config options
*/
use Kirby\Cms\App;
return function (App $kirby) {
$fields = [];
foreach ($kirby->option('tobimori.seo.socialMedia') as $key => $value) {
if ($value) {
$fields[$key] = [
'label' => ucfirst($key),
'type' => 'url',
'icon' => strtolower($key),
'placeholder' => $value
];
}
}
return [
'label' => 'social-media-accounts',
'type' => 'object',
'help' => 'social-media-accounts-help',
'fields' => $fields
];
};

View file

@ -0,0 +1,29 @@
label: metadata-site
icon: search
columns:
main:
width: 7/12
fields:
metaGroup: seo/fields/meta-group
ogGroup: seo/fields/og-group
robots: seo/fields/robots
metaInherit:
label: inherit-settings
type: multiselect
help: inherit-settings-help
options:
metaTemplate: "{{ t('meta-title-template') }}"
metaDescription: "{{ t('meta-description') }}"
ogTemplate: "{{ t('og-title-template') }}"
ogDescription: "{{ t('og-description') }}"
ogImage: "{{ t('og-image') }}"
twitterCardType: "{{ t('twitter-card-type') }}"
twitterAuthor: "{{ t('twitter-author') }}"
robots: '{{ t("robots") }}'
sidebar:
width: 5/12
sticky: true
sections:
seoPreview:
type: seo-preview

View file

@ -0,0 +1,70 @@
label: metadata-site
icon: search
columns:
main:
width: 7/12
fields:
metaHeadline:
label: global-meta-headline
type: headline
numbered: false
help: global-meta-headline-help
metaTemplate:
label: meta-title-template
type: text
help: meta-title-template-help
metaDescription:
label: meta-description
type: textarea
help: meta-description-help
buttons: false
seoLine1:
type: line
ogHeadline:
label: global-og-headline
type: headline
numbered: false
help: global-og-headline-help
ogTemplate:
label: og-title-template
type: text
default: '{{ title }}'
help: meta-title-template-help
placeholder: '{{ site.metaTemplate }}'
ogDescription:
label: og-description
type: textarea
buttons: false
placeholder: '{{ site.metaDescription }}'
ogSiteName:
label: og-site-name
type: text
default: '{{ site.title }}'
placeholder: '{{ site.title }}'
width: 1/2
ogImage:
label: og-image
extends: seo/fields/og-image
empty: og-image-empty
width: 1/2
twitterCardType:
label: twitter-card-type
width: 1/2
type: select
default: summary
required: true
options:
summary: "{{ t('summary') }}"
summary_large_image: "{{ t('summary_large_image') }}"
help: twitter-card-type-help
seoLine2:
type: line
robots: seo/fields/site-robots
socialMediaAccounts: seo/fields/social-media
sidebar:
width: 5/12
sticky: true
sections:
seoPreview:
type: seo-preview