diff --git a/composer.json b/composer.json index d3864ae..b5b2a81 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,8 @@ }, "require": { "php": "~8.1.0 || ~8.2.0 || ~8.3.0 || ~8.4.0", - "getkirby/cms": "^5.0" + "getkirby/cms": "^5.0", + "tobimori/kirby-seo": "^2.0.0-alpha" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 202dd34..d48a949 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "0b7fb803e22a45eb87e24172337208aa", + "content-hash": "004839935ba1e159da0282046c6f3e0d", "packages": [ { "name": "christian-riesen/base32", @@ -1207,12 +1207,81 @@ } ], "time": "2025-08-27T11:34:33+00:00" + }, + { + "name": "tobimori/kirby-seo", + "version": "2.0.0-alpha.12", + "source": { + "type": "git", + "url": "https://github.com/tobimori/kirby-seo.git", + "reference": "910024c55540be63b85d59cfb7152e65417ce6ee" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tobimori/kirby-seo/zipball/910024c55540be63b85d59cfb7152e65417ce6ee", + "reference": "910024c55540be63b85d59cfb7152e65417ce6ee", + "shasum": "" + }, + "require": { + "getkirby/composer-installer": "^1.2.1", + "php": ">=8.3.0" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^3.48", + "getkirby/cli": "^1.8.0", + "getkirby/cms": "^5.0.0", + "spatie/schema-org": "^3.23", + "tobimori/kirby-queues": "^1.0.0-beta.1" + }, + "suggest": { + "getkirby/cli": "Enable background processing support", + "spatie/schema-org": "Enable the Schema.org support", + "tobimori/kirby-queues": "Enable background processing support" + }, + "type": "kirby-plugin", + "extra": { + "kirby-cms-path": false + }, + "autoload": { + "psr-4": { + "tobimori\\Seo\\": "classes" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "proprietary" + ], + "authors": [ + { + "name": "Tobias Möritz", + "email": "tobias@moeritz.io" + } + ], + "description": "The default choice for SEO on Kirby: Implement technical SEO & Meta best practices with ease and provide an easy-to-use editor experience", + "homepage": "https://github.com/tobimori/kirby-seo#readme", + "support": { + "issues": "https://github.com/tobimori/kirby-seo/issues", + "source": "https://github.com/tobimori/kirby-seo/tree/2.0.0-alpha.12" + }, + "funding": [ + { + "url": "https://plugins.andkindness.com/seo/preorder", + "type": "custom" + }, + { + "url": "https://github.com/tobimori", + "type": "github" + } + ], + "time": "2026-01-21T11:45:12+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "tobimori/kirby-seo": 15 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/site/plugins/kirby-seo/LICENSE.md b/site/plugins/kirby-seo/LICENSE.md new file mode 100644 index 0000000..ad5f823 --- /dev/null +++ b/site/plugins/kirby-seo/LICENSE.md @@ -0,0 +1,132 @@ +# Plugin License Agreement + +Source: https://plugins.andkindness.com/license-agreement + +While most of our plugins source code are publicly available, they are, unless specified otherwise, not free software. To use any plugin in production, you need to purchase a license. + +## Summary + +> This is a legally non-binding summary. Please review the full license text carefully before using the plugins. + +This is a legal agreement between you (the customer) and Love & Kindness GmbH for using their Kirby CMS plugins. By downloading or using the plugins, or by purchasing a license, you agree to these terms: + +### What You Can Do + +- **Install and use the plugin on one website or multi-language website per license purchase** + If you need a separate Kirby CMS license for your site, you'll most likely also need a separate plugin license +- **Make copies of the plugin for backup or development purposes** +- **Modify the source code for your own use** + +### What You Cannot Do + +- **Use the plugin on additional websites without buying additional licenses** +- **Redistribute or resell the plugin or your modified versions** + +### Support & Updates + +- **Free updates for minor/patch releases, paid upgrades for major releases possible** +- **Email support provided for active license holders** + +--- + +This license is a legal agreement between **You** and **Love & Kindness GmbH, Beimoorstr. 20, 22081 Hamburg, Germany** (therein "**Our**"/"**We**"/"**Us**") for the use of any Kirby CMS plugins and resources (the "**Plugin**") created by Us and sold via Paddle.com. By downloading any Plugin files or resources or purchasing a license to the Plugin, you agree to be bound by the terms and conditions of this license. + +## Permitted Use + +This agreement grants a license for each purchase to install and use a single instance of the Plugin on a **specific website** limited by **its domain & subdomain**. If You use the cross-domain multi-language feature with the same `content` folder, these domains count as the same Website. + +Additional Plugin licenses must be purchased in order to install and use the Plugin on **additional websites**. + +The license is **non-exclusive** and **generally non-transferable**. + +A license is valid for all minor & patch updates of the Plugin (e.g. 1.0.x to 1.1.x). We reserve the right to charge an **upgrade fee for major updates** (e.g. 1.x.x to 2.x.x). Whether a release is a patch, minor, or major release is at Our sole discretion. + +## Development Usage + +You are permitted to install and use the Plugin on a personal computer (such as a desktop PC, notebook, or tablet) or a server, free of charge, for as long as necessary during the development stage. + +Any website that is used **purely for the purposes of development and client preview** is considered development usage. It must only be accessible by a restricted number of users. A website with **the intention to handle production data** is never considered development usage, no matter if the related website is publicly accessible or not. + +## Refund Policy + +We offer refunds on the Plugin within **14 days of purchase**. Contact support@andkindness.com for assistance. + +## Technical Support + +Technical support is available via email for active license owners. + +No support is provided for free plugins or plugins that are available both for free and paid usage. We do not provide phone support. No representations or guarantees are made regarding the response time in which support questions are answered, but we will do our very best to respond quickly. + +## All Rights Reserved + +Love & Kindness GmbH **owns all rights**, title and interest to the Plugin (including all intellectual property rights) and **reserves all rights to the Plugin** that are not expressly granted in this Agreement. + +## Restrictions + +### Making Copies + +You may make **copies of the Plugin** in any machine readable form solely for purposes of **deploying a website to a server, developing a website on a personal computer or server or as a backup**, provided that You reproduce the Plugin in its original form and with all proprietary notices on the copy. + +You may not reproduce the Plugin or its source code, in whole or in part, for **any other purpose**. + +### Modification of the Source Code + +You may **alter, modify or extend the source code** for Your own use. You may also **commission a third party** to perform those modifications for You. + +However You may not **alter or circumvent the licensing features**, including (but not limited to) the license validation or **resell, redistribute or transfer** the modified or derivative version. + +### Ownership and Intellectual Property + +The Plugin is copyrighted by Us. All rights not expressly granted to You are retained by Us, including intellectual property rights. + +### Disclaimer of Warranty + +THE PLUGIN IS OFFERED ON AN **"AS-IS" BASIS** AND **NO WARRANTY**, EITHER EXPRESSED OR IMPLIED, IS GIVEN. WE EXPRESSLY DISCLAIM ALL WARRANTIES OF ANY KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. YOU ASSUME ALL RISK ASSOCIATED WITH THE QUALITY, PERFORMANCE, INSTALLATION AND USE OF THE PLUGIN INCLUDING, BUT NOT LIMITED TO, THE RISKS OF PROGRAM ERRORS, DAMAGE TO EQUIPMENT, LOSS OF DATA OR SOFTWARE PROGRAMS, OR UNAVAILABILITY OR INTERRUPTION OF OPERATIONS. **YOU ARE SOLELY RESPONSIBLE** FOR DETERMINING THE APPROPRIATENESS OF USE OF THE PLUGIN AND ASSUME ALL RISKS ASSOCIATED WITH ITS USE. THIS PARAGRAPH ALSO APPLIES TO YOU IF YOU ARE NOT THE LICENSEE (E.G. IF YOU USE THE PLUGIN WHILE SOMEONE ELSE IS THE LICENSEE). + +### Limitations of Liability + +YOU EXPRESSLY UNDERSTAND AND AGREE THAT **WE SHALL NOT BE LIABLE** FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, CONSEQUENTIAL OR EXEMPLARY DAMAGES, INCLUDING BUT NOT LIMITED TO, DAMAGES FOR LOSS OF PROFITS, GOODWILL, USE, DATA OR OTHER INTANGIBLE LOSSES (EVEN IF WE HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES). SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF THE LIMITATION OR EXCLUSION OF LIABILITY FOR INCIDENTAL OR CONSEQUENTIAL DAMAGES. ACCORDINGLY, **SOME OF THE ABOVE LIMITATIONS MAY NOT APPLY TO YOU**. **IN NO EVENT WILL OUR TOTAL CUMULATIVE DAMAGES EXCEED** THE FEES YOU PAID TO US UNDER THIS AGREEMENT IN THE MOST RECENT TWELVE-MONTH PERIOD. THIS PARAGRAPH ALSO APPLIES TO YOU IF YOU ARE NOT THE LICENSEE (E.G. IF YOU USE THE PLUGIN WHILE SOMEONE ELSE IS THE LICENSEE). + +## Termination + +The License may be terminated by either party if terms are breached and not remedied within a specified period. + +## Governing Law + +Any legal disputes that arise from or relate to this Agreement shall be exclusively resolved in the courts located in Hamburg, Germany. Nonetheless, we reserve the right to initiate legal proceedings against you in the jurisdiction where your principal place of business is situated. + +Should you be domiciled in Germany, the stipulations of the first paragraph will be relevant only if you are a businessperson, a public law entity, or a special fund under public law. + +If your domicile is not in Germany but within another member state of the European Union, the provisions of the first paragraph will apply to you only if you do not qualify as a consumer as defined under Article 17 of Regulation (EU) No. 1215/2012. In such circumstances, you may bring a legal action against us either in the jurisdiction of our place of business or where you habitually reside. Conversely, we are entitled to sue you exclusively in the courts of the member state where you have your domicile. + +In the event that your residence is outside Germany and not within any European Union member state, the provisions of the first paragraph are fully applicable without any modification. + +## Severability Clause + +Should any provision of this Agreement be or become invalid, void or unenforceable, in whole or in part, at present or in the future, this shall not affect the validity of the remaining provisions of this Agreement. The same shall apply if a gap requiring supplementation arises after conclusion of this Agreement. The parties shall replace the invalid, void or unenforceable provision or gap requiring filling by a valid provision which in its legal or economic content takes account of the invalid, void provision and the overall content of the agreement. § 139 BGB (partial invalidity) is expressly waived. + +--- + +Kirby SEO 1.x releases were previously licensed under the MIT License. + +MIT License + +Copyright (c) 2023-2024 Tobias Möritz + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/site/plugins/kirby-seo/README.md b/site/plugins/kirby-seo/README.md new file mode 100644 index 0000000..2baf05d --- /dev/null +++ b/site/plugins/kirby-seo/README.md @@ -0,0 +1,52 @@ +![Kirby SEO Banner](/.github/new-banner.png) + +

Kirby SEO

+

+ The default choice for SEO on Kirby: Implement technical SEO & Meta best practices with ease and provide an easy-to-use editor experience +

+ +--- + +## Features + +- 🔎 All-in-one SEO and meta solution +- 🪜 The Meta Cascade: Intelligently merge metadata from multiple sources +- 🎛 Completely configurable: Disable features you don't need +- 💻 Simple Panel UI with previews for Google, Twitter, Facebook & Co. +- 📮 [Schema.org (JSON-LD)](https://schema.org/) support with fluent classes +- 🤖 Automatic Robots rule generation, based on page status +- 📝 Sitemap generation with multi-lang support + +### New in Version 2 + +- 🚀 Kirby 5 support +- 💻 Even better and easier Panel UI +- ✨ AI assist for writing meta tags +- 🔘 IndexNow support + +## Get started + +[Read the documentation](https://plugins.andkindness.com/seo/docs/get-started/feature-overview) to get started with Kirby SEO. + +If you're looking to use Kirby SEO with Kirby 5 or newer, please install the Alpha version of the plugin: + +`composer require tobimori/kirby-seo:^2.0.0-alpha.8` + +### What does Alpha mean for Kirby SEO 2? + +The core features of Kirby SEO, such as the meta cascade, the panel setup, sitemap and robots are stable and can be used in production. New features of v2 might be unstable or can occur breaking changes until the final release. + +## Contributing + +Kirby SEO is open to contributors: If you open a pull request that gets merged, such as fixing a bug or translating the plugin into a new language, you're eligible for a free SEO license of your choice. Please note that I might reject minor repeat contributions or simple fixes of typos for this. Please send an email to support after your contribution has been merged. + +## License + +Kirby SEO 2.0 is not free software. In order to run it on a public server, you'll have to purchase a valid Kirby license & a valid SEO license. +**The plugin is currently free to use while in pre-release state.** You can [pre-order a license](https://plugins.andkindness.com/seo/preorder) with a 20% discount for a limited time. + +Copyright 2023-2025 © Tobias Möritz - Love & Kindness GmbH + +--- + +[Kirby SEO 1.0 is licensed under the MIT license.](./LICENSE.md) diff --git a/site/plugins/kirby-seo/blueprints/fields/meta-group.yml b/site/plugins/kirby-seo/blueprints/fields/meta-group.yml new file mode 100644 index 0000000..7b9bb60 --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/meta-group.yml @@ -0,0 +1,34 @@ +type: group +fields: + _metaHeadline: + label: seo.page.meta.headline + type: headline + numbered: false + metaTitle: + label: seo.fields.titleOverwrite.label + type: seo-writer + ai: title + placeholder: "{{ page.title }}" + metaTemplate: + extends: seo/fields/title-template + label: seo.fields.metaTitleTemplate.label + help: seo.fields.metaTitleTemplate.help + width: 2/3 + placeholder: "{{ page.metadata.metaTemplate }}" + useTitleTemplate: + label: seo.fields.useTitleTemplate.label + type: toggle + help: seo.fields.useTitleTemplate.help + width: 1/3 + default: true + text: + - "{{ t('seo.fields.useTitleTemplate.no') }}" + - "{{ t('seo.fields.useTitleTemplate.yes') }}" + metaDescription: + label: seo.fields.metaDescription.label + type: seo-writer + ai: description + help: seo.fields.metaDescription.help + placeholder: "{{ page.metadata.metaDescription }}" + _seoLine1: + type: line diff --git a/site/plugins/kirby-seo/blueprints/fields/og-group.yml b/site/plugins/kirby-seo/blueprints/fields/og-group.yml new file mode 100644 index 0000000..3689e8e --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/og-group.yml @@ -0,0 +1,42 @@ +type: group +fields: + _ogHeadline: + label: seo.page.og.headline + type: headline + numbered: false + help: seo.site.og.headline.help + ogTemplate: + extends: seo/fields/title-template + label: seo.fields.ogTitleTemplate.label + width: 2/3 + help: seo.fields.metaTitleTemplate.help + placeholder: "{{ page.metadata.ogTemplate }}" + useOgTemplate: + label: seo.fields.useTitleTemplate.label + type: toggle + help: seo.fields.useTitleTemplate.help + width: 1/3 + default: true + text: + - "{{ t('seo.fields.useTitleTemplate.no') }}" + - "{{ t('seo.fields.useTitleTemplate.yes') }}" + ogDescription: + label: seo.fields.ogDescription.label + type: seo-writer + ai: og-description + placeholder: "{{ page.metadata.ogDescription }}" + ogImage: + label: seo.fields.ogImage.label + extends: seo/fields/og-image + empty: seo.fields.ogImage.empty + cropOgImage: + label: seo.fields.cropOgImage.label + type: select + width: 1/1 + placeholder: "{{ t('seo.common.default') }} {{ site.cropOgImage.toBool ? t('seo.common.yes') : t('seo.common.no') }}" + options: + "true": "{{ t('seo.common.yes') }}" + "false": "{{ t('seo.common.no') }}" + help: seo.fields.cropOgImage.help + _seoLine2: + type: line diff --git a/site/plugins/kirby-seo/blueprints/fields/og-image.php b/site/plugins/kirby-seo/blueprints/fields/og-image.php new file mode 100644 index 0000000..372a62d --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/og-image.php @@ -0,0 +1,31 @@ + 'files', + 'multiple' => false, + 'uploads' => [], + 'query' => 'model.images' + ]; + + 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; +}; diff --git a/site/plugins/kirby-seo/blueprints/fields/robots.php b/site/plugins/kirby-seo/blueprints/fields/robots.php new file mode 100644 index 0000000..b3c649c --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/robots.php @@ -0,0 +1,56 @@ + 'hidden' + ]; + } + + $fields = [ + '_robotsHeadline' => [ + 'label' => 'seo.fields.robots.label', + 'type' => 'headline', + 'numbered' => false, + ] + ]; + + $page = Meta::currentPage(); + foreach ($kirby->option('tobimori.seo.robots.types') as $robots) { + $upper = Str::ucfirst($robots); + + $fields["robots{$upper}"] = [ + 'label' => "seo.fields.robots.{$robots}.label", + 'type' => 'toggles', + 'help' => "seo.fields.robots.{$robots}.help", + 'width' => '1/2', + 'default' => 'default', + 'reset' => false, + 'options' => [ + 'default' => $page ? + A::join([ + t('seo.common.default'), + $page->metadata()->get("robots{$upper}", ['fields'])->toBool() ? t('seo.common.yes') : t('seo.common.no') + ], ' ') + : t('seo.common.default'), + 'true' => t('seo.common.yes'), + 'false' => t('seo.common.no'), + ] + ]; + } + + $fields['_seoLine3'] = [ + 'type' => 'line' + ]; + + return [ + 'type' => 'group', + 'fields' => $fields, + ]; +}; diff --git a/site/plugins/kirby-seo/blueprints/fields/site-robots.php b/site/plugins/kirby-seo/blueprints/fields/site-robots.php new file mode 100644 index 0000000..55d5b09 --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/site-robots.php @@ -0,0 +1,49 @@ +option('tobimori.seo.robots.active') || !$kirby->option('tobimori.seo.robots.pageSettings')) { + return [ + 'type' => 'hidden' + ]; + } + + $fields = [ + '_robotsHeadline' => [ + 'label' => 'seo.fields.robots.label', + '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' => "seo.fields.robots.{$robots}.label", + 'type' => 'toggles', + 'help' => "seo.fields.robots.{$robots}.help", + 'width' => '1/2', + 'default' => 'default', + 'reset' => false, + 'options' => [ + 'default' => t('seo.common.default') . ' ' . ($index ? t('seo.common.yes') : t('seo.common.no')), + 'true' => t('seo.common.yes'), + 'false' => t('seo.common.no'), + ] + ]; + } + + $fields['_seoLine3'] = [ + 'type' => 'line' + ]; + + return [ + 'type' => 'group', + 'fields' => $fields, + ]; +}; diff --git a/site/plugins/kirby-seo/blueprints/fields/social-media.php b/site/plugins/kirby-seo/blueprints/fields/social-media.php new file mode 100644 index 0000000..3bcf21e --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/social-media.php @@ -0,0 +1,30 @@ + $value) { + if ($value) { + $fields[$key] = [ + 'label' => ucfirst($key), + 'type' => 'url', + 'icon' => strtolower($key), + 'placeholder' => $value + ]; + } + } + + return [ + 'label' => 'seo.fields.socialMediaAccounts.label', + 'type' => 'object', + 'help' => 'seo.fields.socialMediaAccounts.help', + 'fields' => $fields + ]; +}; diff --git a/site/plugins/kirby-seo/blueprints/fields/title-template.yml b/site/plugins/kirby-seo/blueprints/fields/title-template.yml new file mode 100644 index 0000000..4b058ba --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/fields/title-template.yml @@ -0,0 +1,6 @@ +type: seo-writer +nodes: + - seoTemplateTitle + - seoTemplateSiteTitle +toolbar: + inline: false diff --git a/site/plugins/kirby-seo/blueprints/page.php b/site/plugins/kirby-seo/blueprints/page.php new file mode 100644 index 0000000..1c7b5a4 --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/page.php @@ -0,0 +1,60 @@ + 'seo.tabs.seo', + 'icon' => 'search', + 'columns' => [ + 'main' => [ + 'width' => '7/12', + 'fields' => [ + 'metaGroup' => 'seo/fields/meta-group', + 'ogGroup' => 'seo/fields/og-group', + 'robots' => 'seo/fields/robots', + 'metaInherit' => [ + 'label' => 'seo.fields.inheritSettings.label', + 'type' => 'multiselect', + 'help' => 'seo.fields.inheritSettings.help', + 'options' => [ + 'metaTemplate' => [ + '*' => 'seo.fields.metaTitleTemplate.label' + ], + 'metaDescription' => [ + '*' => 'seo.fields.metaDescription.label' + ], + 'ogTemplate' => [ + '*' => 'seo.fields.ogTitleTemplate.label' + ], + 'ogDescription' => [ + '*' => 'seo.fields.ogDescription.label' + ], + 'ogImage' => [ + '*' => 'seo.fields.ogImage.label' + ], + 'cropOgImage' => [ + '*' => 'seo.fields.cropOgImage.label' + ], + 'robots' => [ + '*' => 'seo.fields.robots.label' + ] + ] + ] + ] + ], + 'sidebar' => [ + 'width' => '5/12', + 'sticky' => true, + 'sections' => [ + 'seoPreview' => [ + 'type' => 'seo-preview' + ], + ...(Seo::option('searchConsole.enabled') ? [ + 'seoSearchConsole' => [ + 'type' => 'seo-search-console' + ] + ] : []) + ] + ] + ] +]; diff --git a/site/plugins/kirby-seo/blueprints/seo.php b/site/plugins/kirby-seo/blueprints/seo.php new file mode 100644 index 0000000..78f20b9 --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/seo.php @@ -0,0 +1,15 @@ +request()->url()->toString(); + $isSite = Str::contains($path, '/site') && !Str::contains($path, '/pages/'); + + if ($isSite) { + return require __DIR__ . '/site.php'; + } + + return require __DIR__ . '/page.php'; +}; diff --git a/site/plugins/kirby-seo/blueprints/site.php b/site/plugins/kirby-seo/blueprints/site.php new file mode 100644 index 0000000..7a6d2ec --- /dev/null +++ b/site/plugins/kirby-seo/blueprints/site.php @@ -0,0 +1,95 @@ + 'seo.tabs.seo', + 'icon' => 'search', + 'columns' => [ + 'main' => [ + 'width' => '7/12', + 'fields' => [ + '_metaHeadline' => [ + 'label' => 'seo.site.meta.headline', + 'type' => 'headline', + 'help' => 'seo.site.meta.headline.help' + ], + 'metaTemplate' => [ + 'extends' => 'seo/fields/title-template', + 'label' => 'seo.fields.metaTitleTemplate.label', + 'help' => 'seo.fields.metaTitleTemplate.help' + ], + 'metaDescription' => [ + 'label' => 'seo.fields.metaDescription.label', + 'type' => 'seo-writer', + 'ai' => 'site-description', + 'help' => 'seo.fields.metaDescription.help' + ], + '_seoLine1' => [ + 'type' => 'line' + ], + '_ogHeadline' => [ + 'label' => 'seo.site.og.headline', + 'type' => 'headline', + 'numbered' => false, + 'help' => 'seo.site.og.headline.help' + ], + 'ogTemplate' => [ + 'extends' => 'seo/fields/title-template', + 'label' => 'seo.fields.ogTitleTemplate.label', + 'default' => '{{ title }}', + 'help' => 'seo.fields.metaTitleTemplate.help', + 'placeholder' => '{{ site.metaTemplate }}' + ], + 'ogDescription' => [ + 'label' => 'seo.fields.ogDescription.label', + 'type' => 'seo-writer', + 'ai' => 'og-site-description', + 'placeholder' => '{{ site.metaDescription }}' + ], + 'ogSiteName' => [ + 'label' => 'seo.fields.ogSiteName.label', + 'type' => 'text', + 'default' => '{{ site.title }}', + 'placeholder' => '{{ site.title }}', + 'width' => '1/2' + ], + 'ogImage' => [ + 'label' => 'seo.fields.ogImage.label', + 'extends' => 'seo/fields/og-image', + 'empty' => 'seo.fields.ogImage.empty', + 'width' => '1/2' + ], + 'cropOgImage' => [ + 'label' => 'seo.fields.cropOgImage.label', + 'type' => 'toggle', + 'default' => true, + 'text' => [ + "{{ t('seo.common.no') }}", + "{{ t('seo.common.yes') }}" + ], + 'help' => 'seo.fields.cropOgImage.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' + ], + ...(Seo::option('searchConsole.enabled') ? [ + 'seoSearchConsole' => [ + 'type' => 'seo-search-console' + ] + ] : []) + ] + ] + ] +]; diff --git a/site/plugins/kirby-seo/classes/Ai.php b/site/plugins/kirby-seo/classes/Ai.php new file mode 100644 index 0000000..3cee361 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai.php @@ -0,0 +1,62 @@ +stream($prompt, /* todo custom model here */); + } +} diff --git a/site/plugins/kirby-seo/classes/Ai/Chunk.php b/site/plugins/kirby-seo/classes/Ai/Chunk.php new file mode 100644 index 0000000..e36c076 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Chunk.php @@ -0,0 +1,141 @@ + $message, + 'data' => $payload, + ]); + } + + public function isStreamStart(): bool + { + return $this->type === self::TYPE_STREAM_START; + } + + public function isStreamEnd(): bool + { + return $this->type === self::TYPE_STREAM_END; + } + + public function isTextStart(): bool + { + return $this->type === self::TYPE_TEXT_START; + } + + public function isTextDelta(): bool + { + return $this->type === self::TYPE_TEXT_DELTA; + } + + public function isTextComplete(): bool + { + return $this->type === self::TYPE_TEXT_COMPLETE; + } + + public function isThinkingStart(): bool + { + return $this->type === self::TYPE_THINKING_START; + } + + public function isThinkingDelta(): bool + { + return $this->type === self::TYPE_THINKING_DELTA; + } + + public function isThinkingComplete(): bool + { + return $this->type === self::TYPE_THINKING_COMPLETE; + } + + public function isToolCall(): bool + { + return $this->type === self::TYPE_TOOL_CALL; + } + + public function isToolResult(): bool + { + return $this->type === self::TYPE_TOOL_RESULT; + } + + public function isError(): bool + { + return $this->type === self::TYPE_ERROR; + } +} diff --git a/site/plugins/kirby-seo/classes/Ai/Driver.php b/site/plugins/kirby-seo/classes/Ai/Driver.php new file mode 100644 index 0000000..1817917 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Driver.php @@ -0,0 +1,40 @@ + + */ + abstract public function stream(string $prompt, string|null $model = null): Generator; + + /** + * Returns a configuration value or throws when required. + */ + protected function config(string $key, mixed $default = null, bool $required = false): mixed + { + $value = Seo::option("ai.providers.{$this->providerId}.config.{$key}", $default); + + if ($required === true && ($value === null || $value === '')) { + throw new InvalidArgumentException( + "Missing required \"{$key}\" configuration for driver " . static::class . '.' + ); + } + + return $value; + } +} diff --git a/site/plugins/kirby-seo/classes/Ai/Drivers/Anthropic.php b/site/plugins/kirby-seo/classes/Ai/Drivers/Anthropic.php new file mode 100644 index 0000000..b6e3a83 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Drivers/Anthropic.php @@ -0,0 +1,103 @@ +config('apiKey', required: true); + $headers = [ + 'Content-Type: application/json', + 'Accept: text/event-stream', + "x-api-key: {$apiKey}", + 'anthropic-version: 2023-06-01', + ]; + + $payload = [ + 'model' => $model ?? $this->config('model', static::DEFAULT_MODEL), + 'messages' => [ + ['role' => 'user', 'content' => $prompt] + ], + 'max_tokens' => 4096, + 'stream' => true, + ]; + + $stream = new SseStream($this->config('endpoint', static::DEFAULT_ENDPOINT), $headers, $payload, (int)$this->config('timeout', 120)); + yield from $stream->stream(function (array $event): Generator { + $type = $event['type'] ?? null; + + // handle message start event + if ($type === 'message_start') { + yield Chunk::streamStart($event); + return; + } + + // handle content block start (beginning of text output) + if ($type === 'content_block_start') { + $contentBlock = $event['content_block'] ?? []; + if (($contentBlock['type'] ?? null) === 'text') { + yield Chunk::textStart($event); + } + return; + } + + // handle content block delta (text chunks) + if ($type === 'content_block_delta') { + $delta = $event['delta'] ?? []; + if (($delta['type'] ?? null) === 'text_delta') { + $text = $delta['text'] ?? ''; + if ($text !== '') { + yield Chunk::textDelta($text, $event); + } + } + return; + } + + // handle content block stop (end of text block) + if ($type === 'content_block_stop') { + yield Chunk::textComplete($event); + return; + } + + // handle message stop (end of stream) + if ($type === 'message_stop') { + yield Chunk::streamEnd($event); + return; + } + + // handle ping events (keep-alive) + if ($type === 'ping') { + // ignore ping events + return; + } + + // handle error events + if ($type === 'error') { + $error = $event['error'] ?? []; + $message = $error['message'] ?? 'Unknown Anthropic streaming error.'; + yield Chunk::error($message, $event); + return; + } + + // handle message delta (contains usage info) + if ($type === 'message_delta') { + // we could extract usage info here if needed + return; + } + }); + } +} diff --git a/site/plugins/kirby-seo/classes/Ai/Drivers/OpenAi.php b/site/plugins/kirby-seo/classes/Ai/Drivers/OpenAi.php new file mode 100644 index 0000000..80dbb6d --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Drivers/OpenAi.php @@ -0,0 +1,82 @@ +config('apiKey', required: true); + $headers = [ + 'Content-Type: application/json', + 'Accept: text/event-stream', + "Authorization: Bearer {$apiKey}", + ]; + if ($organization = $this->config('organization')) { + $headers[] = "OpenAI-Organization: {$organization}"; + } + + $payload = [ + 'model' => $model ?? $this->config('model', static::DEFAULT_MODEL), + 'input' => $prompt, + // instructions does not work for e.g. openrouter so let's just put everything in user prompt + 'stream' => true, + ]; + + $stream = new SseStream($this->config('endpoint', static::DEFAULT_ENDPOINT), $headers, $payload, (int)$this->config('timeout', 120)); + yield from $stream->stream(function (array $event): Generator { + $type = $event['type'] ?? null; + + if ($type === 'response.created') { + yield Chunk::streamStart($event); + return; + } + + if ($type === 'response.in_progress') { + yield Chunk::textStart($event); + return; + } + + if ($type === 'response.output_text.delta') { + $delta = $event['delta'] ?? ''; + if ($delta !== '') { + yield Chunk::textDelta($delta, $event); + } + return; + } + + if ($type === 'response.output_text.done') { + yield Chunk::textComplete($event); + return; + } + + if ($type === 'response.completed') { + yield Chunk::streamEnd($event); + return; + } + + if ($type === 'response.output_item.added' && ($event['item']['type'] ?? null) === 'reasoning') { + yield Chunk::thinkingStart($event); + return; + } + + if ($type === 'response.error') { + $message = $event['error']['message'] ?? 'Unknown OpenAI streaming error.'; + yield Chunk::error($message, $event); + } + }); + } +} diff --git a/site/plugins/kirby-seo/classes/Ai/SseStream.php b/site/plugins/kirby-seo/classes/Ai/SseStream.php new file mode 100644 index 0000000..7f43464 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/SseStream.php @@ -0,0 +1,196 @@ + $mapper + * @return Generator + */ + public function stream(callable $mapper): Generator + { + $buffer = ''; + $response = ''; + $handle = curl_init($this->endpoint); + + curl_setopt_array($handle, [ + CURLOPT_POST => true, + CURLOPT_HTTPHEADER => $this->headers, + CURLOPT_POSTFIELDS => json_encode( + $this->payload, + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES + ), + CURLOPT_RETURNTRANSFER => false, + CURLOPT_TIMEOUT => $this->timeout, + CURLOPT_WRITEFUNCTION => static function ($curl, $data) use (&$buffer, &$response) { + $buffer .= $data; + $currentLength = strlen($response); + + if ($currentLength < self::ERROR_CONTEXT_LIMIT) { + $response .= substr($data, 0, self::ERROR_CONTEXT_LIMIT - $currentLength); + } + + return strlen($data); + }, + ]); + + $multi = curl_multi_init(); + curl_multi_add_handle($multi, $handle); + + try { + $running = null; + do { + $status = curl_multi_exec($multi, $running); + + if ($status === CURLM_CALL_MULTI_PERFORM) { + continue; + } + + yield from $this->drainBuffer($buffer, $mapper); + + if ($running) { + curl_multi_select($multi, 0.1); + } + } while ($running); + + yield from $this->drainBuffer($buffer, $mapper, true); + + $errno = curl_errno($handle); + if ($errno) { + throw new KirbyException(curl_error($handle) ?: 'Streaming request failed.', $errno); + } + + $code = curl_getinfo($handle, CURLINFO_HTTP_CODE); + if ($code !== null && $code >= 400) { + $message = sprintf('Streaming request failed (%d)', $code); + $body = trim($response); + + if ($body !== '') { + $decoded = json_decode($body, true); + + if (json_last_error() === JSON_ERROR_NONE && is_array($decoded)) { + $body = $decoded['error']['message'] ?? $decoded['message'] ?? $body; + } + + if (strlen($body) > 200) { + $body = substr($body, 0, 200) . '...'; + } + + $message .= ': ' . preg_replace('/\s+/', ' ', $body); + } + + throw new KirbyException($message); + } + } finally { + curl_multi_remove_handle($multi, $handle); + curl_multi_close($multi); + curl_close($handle); + } + } + + /** + * @param callable(array $event): Generator $mapper + * @return Generator + */ + private function drainBuffer(string &$buffer, callable $mapper, bool $final = false): Generator + { + while ( + preg_match('/\r?\n\r?\n/', $buffer, $match, PREG_OFFSET_CAPTURE) === 1 + ) { + $pos = $match[0][1]; + $len = strlen($match[0][0]); + $frame = substr($buffer, 0, $pos); + $buffer = substr($buffer, $pos + $len); + + foreach ($this->mapFrame($frame, $mapper) as $chunk) { + yield $chunk; + } + } + + if ($final && trim($buffer) !== '') { + foreach ($this->mapFrame($buffer, $mapper) as $chunk) { + yield $chunk; + } + + $buffer = ''; + } + } + + /** + * @param callable(array $event): Generator $mapper + * @return Generator + */ + private function mapFrame(string $frame, callable $mapper): Generator + { + $frame = trim($frame); + + if ($frame === '') { + return; + } + + $payload = ''; + + foreach (preg_split("/\r\n|\n|\r/", $frame) as $line) { + $line = trim($line); + + if ($line === '' || str_starts_with($line, ':')) { + continue; + } + + if (str_starts_with($line, 'data:')) { + $payload .= substr($line, 5); + } + } + + $payload = trim($payload); + if ($payload === '' || $payload === '[DONE]') { + return; + } + + $event = json_decode($payload, true); + if (json_last_error() !== JSON_ERROR_NONE || !is_array($event)) { + return; + } + + yield from $mapper($event); + } +} diff --git a/site/plugins/kirby-seo/classes/Buttons/RobotsViewButton.php b/site/plugins/kirby-seo/classes/Buttons/RobotsViewButton.php new file mode 100644 index 0000000..468655b --- /dev/null +++ b/site/plugins/kirby-seo/classes/Buttons/RobotsViewButton.php @@ -0,0 +1,51 @@ +robots(); + + $theme = 'positive-icon'; + $icon = 'robots'; + $text = I18n::translate('seo.fields.robots.indicator.index'); + + if (Str::contains($robots, 'no') && !Str::contains($robots, 'noindex')) { + $theme = 'notice-icon'; + $icon = 'robots-off'; + $text = I18n::translate('seo.fields.robots.indicator.any'); + } + + if (Str::contains($robots, 'noindex')) { + $theme = 'negative-icon'; + $icon = 'robots-off'; + $text = I18n::translate('seo.fields.robots.indicator.noindex'); + } + + parent::__construct( + model: $model, + icon: $icon, + text: $text, + theme: $theme, + link: $model->panel()->url() . '?tab=seo', + responsive: true + ); + } +} diff --git a/site/plugins/kirby-seo/classes/Buttons/UtmShareViewButton.php b/site/plugins/kirby-seo/classes/Buttons/UtmShareViewButton.php new file mode 100644 index 0000000..014887b --- /dev/null +++ b/site/plugins/kirby-seo/classes/Buttons/UtmShareViewButton.php @@ -0,0 +1,21 @@ +panel()->path()}", + icon: 'share', + title: I18n::translate('seo.utmShare.button') + ); + } +} diff --git a/site/plugins/kirby-seo/classes/Dialogs/UtmShareDialog.php b/site/plugins/kirby-seo/classes/Dialogs/UtmShareDialog.php new file mode 100644 index 0000000..d2db98b --- /dev/null +++ b/site/plugins/kirby-seo/classes/Dialogs/UtmShareDialog.php @@ -0,0 +1,39 @@ +model = $kirby->site(); + } else { + $id = preg_replace('/^pages\//', '', $path); + $this->model = Find::page($id); + } + } + + public function load(): array + { + $url = $this->model instanceof Site + ? $this->model->homePage()->url() + : $this->model->url(); + + return [ + 'component' => 'k-seo-utm-share-dialog', + 'props' => [ + 'pageUrl' => $url + ] + ]; + } +} diff --git a/site/plugins/kirby-seo/classes/GoogleSearchConsole.php b/site/plugins/kirby-seo/classes/GoogleSearchConsole.php new file mode 100644 index 0000000..a71b431 --- /dev/null +++ b/site/plugins/kirby-seo/classes/GoogleSearchConsole.php @@ -0,0 +1,386 @@ +cache('tobimori.seo.searchConsole'); + } + + /** + * Get OAuth credentials from config + */ + public static function credentials(): ?array + { + return Seo::option('searchConsole.credentials.web'); + } + + /** + * Check if credentials are configured + */ + public static function hasCredentials(): bool + { + $credentials = static::credentials(); + return !empty($credentials['client_id']) && !empty($credentials['client_secret']); + } + + /** + * Get the token file path + */ + protected static function tokenPath(): string + { + $path = Seo::option('searchConsole.tokenPath'); + return is_callable($path) ? $path() : $path; + } + + /** + * Load tokens from file + */ + public static function tokens(): ?array + { + if (static::$tokens !== null) { + return static::$tokens; + } + + $path = static::tokenPath(); + if (!F::exists($path)) { + return null; + } + + static::$tokens = Json::read($path); + return static::$tokens; + } + + /** + * Save tokens to file + */ + protected static function saveTokens(array $tokens): void + { + static::$tokens = $tokens; + Json::write(static::tokenPath(), $tokens); + } + + /** + * Check if we have valid tokens + */ + public static function isConnected(): bool + { + $tokens = static::tokens(); + return !empty($tokens['access_token']) && !empty($tokens['refresh_token']); + } + + /** + * Get the authorization URL + */ + public static function authUrl(string $redirectUri, string $state): string + { + $credentials = static::credentials(); + + $uri = new Uri(static::AUTH_URL); + $uri->query()->merge([ + 'client_id' => $credentials['client_id'], + 'redirect_uri' => $redirectUri, + 'response_type' => 'code', + 'access_type' => 'offline', + 'prompt' => 'consent', + 'scope' => static::SCOPES, + 'state' => $state + ]); + + return $uri->toString(); + } + + /** + * Exchange authorization code for tokens + */ + public static function exchangeCode(string $code, string $redirectUri): array + { + $credentials = static::credentials(); + + $response = Remote::request(static::TOKEN_URL, [ + 'method' => 'POST', + 'headers' => [ + 'Content-Type' => 'application/x-www-form-urlencoded' + ], + 'data' => [ + 'client_id' => $credentials['client_id'], + 'client_secret' => $credentials['client_secret'], + 'code' => $code, + 'grant_type' => 'authorization_code', + 'redirect_uri' => $redirectUri + ] + ]); + + $data = $response->json(); + + if (isset($data['error'])) { + throw new \Exception($data['error_description'] ?? $data['error']); + } + + // store tokens with expiry timestamp + $tokens = [ + 'access_token' => $data['access_token'], + 'refresh_token' => $data['refresh_token'], + 'expires_at' => time() + $data['expires_in'] + ]; + + static::saveTokens($tokens); + return $tokens; + } + + /** + * Refresh the access token + */ + public static function refreshToken(): string + { + $credentials = static::credentials(); + $tokens = static::tokens(); + + if (empty($tokens['refresh_token'])) { + throw new \Exception('No refresh token available'); + } + + $response = Remote::request(static::TOKEN_URL, [ + 'method' => 'POST', + 'headers' => [ + 'Content-Type' => 'application/x-www-form-urlencoded' + ], + 'data' => [ + 'client_id' => $credentials['client_id'], + 'client_secret' => $credentials['client_secret'], + 'refresh_token' => $tokens['refresh_token'], + 'grant_type' => 'refresh_token' + ] + ]); + + $data = $response->json(); + + if (isset($data['error'])) { + throw new \Exception($data['error_description'] ?? $data['error']); + } + + $tokens['access_token'] = $data['access_token']; + $tokens['expires_at'] = time() + $data['expires_in']; + + static::saveTokens($tokens); + return $tokens['access_token']; + } + + /** + * Get a valid access token, refreshing if needed + */ + public static function accessToken(): string + { + $tokens = static::tokens(); + + if (empty($tokens['access_token'])) { + throw new \Exception('Not connected to Google Search Console'); + } + + // refresh if expired or expiring soon (within 5 min) + if ($tokens['expires_at'] < time() + 300) { + return static::refreshToken(); + } + + return $tokens['access_token']; + } + + /** + * Get the connected property URL + */ + public static function property(): ?string + { + $tokens = static::tokens(); + return $tokens['property'] ?? null; + } + + /** + * Find the best matching property for a site URL + */ + public static function findMatchingProperty(string $siteUrl): ?string + { + $properties = static::listProperties(); + if (empty($properties)) { + return null; + } + + $siteHost = parse_url($siteUrl, PHP_URL_HOST); + + foreach ($properties as $p) { + $propUrl = $p['siteUrl']; + + // check domain properties (sc-domain:example.com) + if (str_starts_with($propUrl, 'sc-domain:')) { + $domain = substr($propUrl, 10); + if ($domain === $siteHost || str_ends_with($siteHost, ".{$domain}")) { + return $propUrl; + } + } + + // check URL prefix properties + if (str_starts_with($siteUrl, $propUrl) || $propUrl === "{$siteUrl}/") { + return $propUrl; + } + } + + // fallback to first property + return $properties[0]['siteUrl'] ?? null; + } + + /** + * Set the connected property URL + */ + public static function setProperty(string $property): void + { + $tokens = static::tokens() ?? []; + $tokens['property'] = $property; + static::saveTokens($tokens); + } + + /** + * Disconnect (remove tokens) + */ + public static function disconnect(): void + { + $path = static::tokenPath(); + if (F::exists($path)) { + F::remove($path); + } + static::$tokens = null; + } + + /** + * List available GSC properties + */ + public static function listProperties(): array + { + $response = Remote::request('https://www.googleapis.com/webmasters/v3/sites', [ + 'method' => 'GET', + 'headers' => [ + 'Authorization' => 'Bearer ' . static::accessToken() + ] + ]); + + $data = $response->json(); + + if (isset($data['error'])) { + throw new \Exception($data['error']['message'] ?? 'Failed to list properties'); + } + + return $data['siteEntry'] ?? []; + } + + /** + * Query search analytics data (fetches max 25k rows from Google, cached for 24h) + */ + public static function query(array $options = []): array + { + $property = static::property(); + if (!$property) { + throw new \Exception('No property selected'); + } + + $body = [ + 'startDate' => $options['startDate'] ?? date('Y-m-d', strtotime('-28 days')), + 'endDate' => $options['endDate'] ?? date('Y-m-d', strtotime('-1 day')), + 'dimensions' => $options['dimensions'] ?? ['query'], + 'rowLimit' => 25000 + ]; + + if (!empty($options['page'])) { + $body['dimensionFilterGroups'] = [[ + 'filters' => [[ + 'dimension' => 'page', + 'operator' => $options['pageOperator'] ?? 'equals', + 'expression' => $options['page'] + ]] + ]]; + } + + $cacheKey = md5($property . json_encode($body)); + + $cached = static::cache()->get($cacheKey); + if ($cached !== null) { + return $cached; + } + + $uri = new Uri('https://www.googleapis.com/webmasters/v3/sites'); + $uri->setPath($uri->path() . '/' . urlencode($property) . '/searchAnalytics/query'); + + $response = Remote::request($uri->toString(), [ + 'method' => 'POST', + 'headers' => [ + 'Authorization' => 'Bearer ' . static::accessToken(), + 'Content-Type' => 'application/json' + ], + 'data' => json_encode($body) + ]); + + $data = $response->json(); + + if (isset($data['error'])) { + throw new \Exception($data['error']['message'] ?? 'Failed to query search analytics'); + } + + $rows = $data['rows'] ?? []; + + static::cache()->set($cacheKey, $rows, static::CACHE_DURATION); + + return $rows; + } + + /** + * Query search data for a Kirby model (page or site), sorted by metric + */ + public static function queryForModel($model, string $metric = 'clicks', int $limit = 10, bool $asc = false): array + { + if ($model instanceof Page) { + // try exact URL match first + $data = static::query(['page' => $model->url()]); + + // fallback: match by path + if (empty($data)) { + $path = $model->uri(); + if ($path) { + $data = static::query([ + 'page' => "/{$path}", + 'pageOperator' => 'contains' + ]); + } + } + } else { + $data = static::query(); + } + + if (empty($data)) { + return []; + } + + $dir = $asc ? 1 : -1; + usort($data, fn ($a, $b) => match ($metric) { + 'query' => strcasecmp($a['keys'][0], $b['keys'][0]) * $dir, + default => ($a[$metric] <=> $b[$metric]) * $dir + }); + + return array_slice($data, 0, $limit); + } +} diff --git a/site/plugins/kirby-seo/classes/IndexNow.php b/site/plugins/kirby-seo/classes/IndexNow.php new file mode 100644 index 0000000..5d16711 --- /dev/null +++ b/site/plugins/kirby-seo/classes/IndexNow.php @@ -0,0 +1,316 @@ +page = $page; + + // always add the current page if it's indexable + if ($this->isIndexable($page)) { + $this->urls[] = $page->url(); + } + } + + /** + * Collect URLs to be indexed based on rules + */ + public function collect(): self + { + if ($this->collected) { + return $this; + } + + $rules = Seo::option('indexnow.rules') ?? []; + + foreach ($rules as $pattern => $invalidations) { + if (!$this->matchesPattern($pattern)) { + continue; + } + + $this->collectFromRule($invalidations); + } + + $this->urls = array_unique($this->urls); + $this->collected = true; + + return $this; + } + + /** + * Get collected urls + */ + public function urls(): array + { + if (!$this->collected) { + $this->collect(); + } + + return $this->urls; + } + + /** + * Send the collected urls + */ + public function request(): bool + { + if (!$this->collected) { + $this->collect(); + } + + return static::send($this->urls); + } + + /** + * Static method to send urls to indexnow api + */ + public static function send(array $urls): bool + { + if (!Seo::option('indexnow.enabled') || empty($urls)) { + return false; + } + + $firstUrl = $urls[0]; + $parsedUrl = parse_url($firstUrl); + $host = $parsedUrl['host']; + $scheme = $parsedUrl['scheme'] ?? 'https'; + $path = $parsedUrl['path'] ?? ''; + + // don't send requests for local development environments + if (App::instance()->environment()->isLocal()) { + return false; + } + + // get base path (everything before the page path) + $basePath = ''; + if ($path && $path !== '/') { + // find the base path by comparing with site url + $siteUrl = App::instance()->site()->url(); + $siteParsed = parse_url($siteUrl); + $basePath = $siteParsed['path'] ?? ''; + } + + $searchEngine = Seo::option('indexnow.searchEngine'); + $searchEngine = rtrim($searchEngine, '/'); + if (!str_contains($searchEngine, '/indexnow')) { + $searchEngine .= '/indexnow'; + } + + $domainUrls = array_filter($urls, fn ($url) => parse_url($url, PHP_URL_HOST) === $host); + + // split into batches of 10,000 (IndexNow limit) + $batches = array_chunk(array_values(array_unique($domainUrls)), 10000); + $allSuccessful = true; + $key = static::key(); + + foreach ($batches as $batch) { + try { + $response = Remote::post($searchEngine, [ + 'headers' => [ + 'Content-Type' => 'application/json; charset=utf-8', + 'User-Agent' => Seo::userAgent() + ], + 'data' => json_encode([ + 'host' => $host, + 'key' => $key, + 'keyLocation' => "{$scheme}://{$host}{$basePath}/indexnow-{$key}.txt", + 'urlList' => $batch + ]) + ]); + + if ($response->code() > 299) { + $allSuccessful = false; + } + } catch (\Exception $e) { + $allSuccessful = false; + } + } + + return $allSuccessful; + } + + /** + * Get or generate the indexnow key + * Stored in cache so it persists across requests + */ + public static function key(): string + { + return static::$key ??= App::instance()->cache('tobimori.seo.indexnow')->getOrSet('key', fn () => Str::random(32, 'hexLower'), 0); + } + + /** + * Check if a provided key matches the stored key + * Used by the route to verify ownership + */ + public static function verifyKey(string $providedKey): bool + { + return $providedKey === static::key(); + } + + /** + * Check if page matches a pattern (url glob/regex or template) + */ + protected function matchesPattern(string $pattern): bool + { + if ($pattern === '*') { + return true; + } + + // url pattern + if (str_contains($pattern, '/')) { + return $this->matchesUrlPattern($pattern, $this->page->url()); + } + + // template pattern + return $this->page->intendedTemplate()->name() === $pattern; + } + + /** + * Match url pattern (glob style) + */ + protected function matchesUrlPattern(string $pattern, string $url): bool + { + // convert glob to regex + $pattern = str_replace( + ['*', '?', '[', ']'], + ['.*', '.', '\[', '\]'], + $pattern + ); + + return preg_match("#^{$pattern}$#", parse_url($url, PHP_URL_PATH)); + } + + /** + * Collect urls based on invalidation rules + */ + protected function collectFromRule(array $rule): void + { + // parent(s) + if (isset($rule['parent'])) { + $this->collectParents($rule['parent']); + } + + // children + if (isset($rule['children'])) { + $this->collectChildren($rule['children']); + } + + // siblings + if (isset($rule['siblings']) && $rule['siblings'] === true) { + $this->collectSiblings(); + } + + // specific urls + if (isset($rule['urls'])) { + foreach ($rule['urls'] as $url) { + $this->urls[] = url($url); + } + } + + // pages by template + if (isset($rule['templates'])) { + $this->collectByTemplates($rule['templates']); + } + } + + /** + * Collect parent urls + */ + protected function collectParents($levels): void + { + $parent = $this->page->parent(); + $count = is_bool($levels) ? 1 : $levels; + $language = App::instance()->language(); + + while ($parent && $count > 0) { + if ($this->isIndexable($parent)) { + $this->urls[] = $parent->url($language?->code()); + } + $parent = $parent->parent(); + $count--; + } + } + + /** + * Collect children urls + */ + protected function collectChildren($depth): void + { + $maxDepth = is_bool($depth) ? null : $depth; + $language = App::instance()->language(); + + $collectRecursive = function ($page, $currentDepth = 0) use (&$collectRecursive, $maxDepth, $language) { + if ($maxDepth !== null && $currentDepth >= $maxDepth) { + return; + } + + foreach ($page->children() as $child) { + if ($this->isIndexable($child)) { + $this->urls[] = $child->url($language?->code()); + } + $collectRecursive($child, $currentDepth + 1); + } + }; + + $collectRecursive($this->page); + } + + /** + * Collect sibling urls + */ + protected function collectSiblings(): void + { + if (!$this->page->parent()) { + return; + } + + $language = App::instance()->language(); + + foreach ($this->page->siblings() as $sibling) { + if ($this->isIndexable($sibling)) { + $this->urls[] = $sibling->url($language?->code()); + } + } + } + + /** + * Collect urls by template names + */ + protected function collectByTemplates(array $templates): void + { + $language = App::instance()->language(); + + $pages = $this->page->site()->index() + ->filterBy('intendedTemplate', 'in', $templates) + ->filter($this->isIndexable(...)); + + foreach ($pages as $page) { + $this->urls[] = $page->url($language?->code()); + } + } + + /** + * Check if a page is indexable (robots allow + listed) + */ + protected function isIndexable(Page $page): bool + { + return $page->isListed() + && $page->robots() !== 'noindex' + && $page->robots() !== 'none'; + } +} diff --git a/site/plugins/kirby-seo/classes/Meta.php b/site/plugins/kirby-seo/classes/Meta.php new file mode 100644 index 0000000..ac12f67 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Meta.php @@ -0,0 +1,743 @@ +page = $page; + $this->lang = $lang ?? kirby()->language(); + + if (method_exists($this->page, 'metaDefaults')) { + $this->metaDefaults = $this->page->metaDefaults($this->lang?->code()); + } + } + + /** + * Normalize a locale string to use a specific separator + * + * @param string $locale The locale string (e.g., 'en_US.UTF-8', 'en-US', 'en_US') + * @param string $separator The separator to use ('-' for BCP47/hreflang, '_' for Open Graph) + * @return string The normalized locale (e.g., 'en-US' or 'en_US') + */ + public static function normalizeLocale(string $locale, string $separator = '-'): string + { + // encoding suffix if present (e.g., '.UTF-8') + $locale = Str::contains($locale, '.') ? Str::before($locale, '.') : $locale; + + // target both underscores and hyphens + $locale = Str::replace($locale, '_', $separator); + $locale = Str::replace($locale, '-', $separator); + + return $locale; + } + + /** + * Convert a Language to BCP 47 language tag format for hreflang attributes + * + * @param Language $language + * @return string The BCP 47 compliant language tag (e.g., 'en-US', 'de-DE') + */ + public static function toBCP47(Language $language): string + { + return self::normalizeLocale($language->locale(LC_ALL), '-'); + } + + /** + * Convert a Language to Open Graph locale format + * + * @param Language $language + * @return string The Open Graph locale format (e.g., 'en_US', 'de_DE') + */ + public static function toOpenGraphLocale(Language $language): string + { + return self::normalizeLocale($language->locale(LC_ALL), '_'); + } + + /** + * Returns the meta array which maps meta tags to their fieldnames + */ + protected function metaArray(): array + { + if ($this->metaArray) { + return $this->metaArray; + } + + // We have to specify field names and resolve them later, so we can use this + // function to resolve meta tags from field names in the programmatic function + $meta = + [ + 'title' => 'metaTitle', + 'description' => 'metaDescription', + 'date' => fn () => $this->page->modified($this->dateFormat()), + 'og:title' => 'ogTitle', + 'og:description' => 'ogDescription', + 'og:site_name' => 'ogSiteName', + 'og:image' => 'ogImage', + 'og:image:width' => fn () => $this->ogImageThumb()?->width() ?? null, + 'og:image:height' => fn () => $this->ogImageThumb()?->height() ?? null, + 'og:image:alt' => fn () => $this->get('ogImage')->toFile()?->alt() ?? null, + 'og:type' => 'ogType', + ]; + + + // Robots + if ($robotsActive = Seo::option('robots.active')) { + $meta['robots'] = $this->robots(...); + } + + // only add canonical and alternate tags if the page is indexable + // we have to resolve this lazily (using a callable) to avoid an infinite loop + $allowsIndexFn = fn () => !$robotsActive || !Str::contains($this->robots(), 'noindex'); + + // canonical + $canonicalFn = fn () => $allowsIndexFn() ? $this->canonicalUrl() : null; + $meta['canonical'] = $canonicalFn; + $meta['og:url'] = $canonicalFn; + + // Check if the current URL is canonical + // Compare the current request URL with the canonical URL + $currentUrl = kirby()->request()->url()->toString(); + $canonicalUrl = $this->canonicalUrl(); + $isCanonical = $currentUrl === $canonicalUrl; + + // Multi-lang alternate tags + // Skip hreflang tags if URL is not canonical (has query params, Kirby params, etc.) + if (kirby()->languages()->count() > 1 && $this->lang !== null && $isCanonical) { + foreach (kirby()->languages() as $lang) { + // only if this language is translated for this page and exists + // note: can be checked now, does not cause infinite loop + if (!$this->page->translation($lang->code())->exists()) { + continue; + } + + // only add alternate tags if the page is indexable + $meta['alternate'][] = fn () => $allowsIndexFn() ? [ + 'hreflang' => Meta::toBCP47($lang), + 'href' => $this->page->url($lang->code()), + 'rel' => 'alternate', + ] : null; + + if ($lang !== $this->lang) { + $meta['og:locale:alternate'][] = fn () => Meta::toOpenGraphLocale($lang); + } + } + + // x-default: language-neutral URL for users whose language doesn't match any translation + // indexUrl() strips the language prefix so the server can handle language detection + // see config/page-methods.php for details and customization + $meta['alternate'][] = fn () => $allowsIndexFn() ? [ + 'hreflang' => 'x-default', + 'href' => $this->page->indexUrl(), + 'rel' => 'alternate', + ] : null; + $meta['og:locale'] = fn () => Meta::toOpenGraphLocale($this->lang); + } else { + // Single-language site: get locale from cascade (will fallback to 'locale' option) + $meta['og:locale'] = fn () => Meta::normalizeLocale($this->get('locale')->value(), '_'); + } + + // If URL is not canonical, also skip og:locale:alternate tags + if (!$isCanonical) { + unset($meta['og:locale:alternate']); + } + + $meta['me'] = fn () => ( + ($socialMedia = $this->site('socialMediaAccounts')?->toObject()) + && ($mastodon = $socialMedia->mastodon()->value()) + ) ? $mastodon : null; + + // This array will be normalized for use in the snippet in $this->snippetData() + return $this->metaArray = $meta; + } + + /** + * This array defines what HTML tag the corresponding meta tags are using including the attributes, + * so everything is a bit more elegant when defining programmatic content (supports regex) + */ + public const TAG_TYPE_MAP = [ + [ + 'tag' => 'title', + 'priority' => true, + 'tags' => [ + 'title' + ] + ], + [ + 'tag' => 'link', + 'attributes' => [ + 'name' => 'rel', + 'content' => 'href', + ], + 'tags' => [ + 'me', + 'canonical', + 'alternate', + ] + ], + [ + 'tag' => 'meta', + 'attributes' => [ + 'name' => 'property', + 'content' => 'content', + ], + 'tags' => [ + '/og:.+/' + ] + ] + ]; + + /** + * Normalize the meta array and remaining meta defaults to be used in the snippet, + * also resolve the content, if necessary + */ + public function snippetData(?array $raw = null): array + { + $mergeWithDefaults = !isset($raw); + $raw ??= $this->metaArray(); + $tags = []; + + foreach ($raw as $name => $value) { + // if the key is numeric, it is already normalized to the correct array syntax + if (is_numeric($name)) { + // but we still check if the array is valid + if (!is_array($value) || count(array_intersect(['tag', 'content', 'attributes'], array_keys($value))) !== count($value)) { + throw new InvalidArgumentException("[Kirby SEO] Invalid array structure found in programmatic content for page {$this->slug()}. Please check your metaDefaults method for template {$this->template()->name()}."); + } + + $tags[] = $value; + continue; + } + + // allow overrides from metaDefaults for keys that are a callable or array by default + // (all fields from meta array that are not part of the regular cascade) + if ((is_callable($value) || is_array($value)) && $mergeWithDefaults && array_key_exists($name, $this->metaDefaults)) { + $this->consumed[] = $name; + $value = $this->metaDefaults[$name]; + } + + // if the value is a string, we know it's a field name + if (is_string($value)) { + $value = $this->$value($name); + } + + // if the value is a callable, we resolve it + if (is_callable($value)) { + $value = $value($this->page); + } + + // if the value is empty, we don't want to output it + if ((is_a($value, Field::class) && $value->isEmpty()) || !$value) { + continue; + } + + // resolve the tag type from the meta array + // so we can use the correct attributes to normalize it + $tag = $this->resolveTag($name); + + // if the value is an associative array now, all of them are attributes + // and we don't look for what the TAG_TYPE_MAP says + // or there should be multiple tags with the same name (non-associative array) + if (is_array($value)) { + if (!A::isAssociative($value)) { + foreach ($value as $val) { + $tags = array_merge($tags, $this->snippetData([$name => $val])); + } + continue; + } + + // array is associative, so it's an array of attributes + // we resolve the values, if they are callable + array_walk($value, function (&$item) { + if (is_callable($item)) { + $item = $item($this->page); + } + }); + + // add the tag to the array + $tags[] = [ + 'tag' => $tag['tag'], + 'attributes' => $value, + 'content' => null, + 'priority' => $tag['priority'] ?? false, + ]; + continue; + } + + // if the value is a string, we use the TAG_TYPE_MAP + // to correctly map the attributes + $tags[] = [ + 'tag' => $tag['tag'], + 'attributes' => isset($tag['attributes']) ? [ + $tag['attributes']['name'] => $name, + $tag['attributes']['content'] => $value, + ] : null, + 'content' => !isset($tag['attributes']) ? $value : null, + 'priority' => $tag['priority'] ?? false, + ]; + } + + if ($mergeWithDefaults) { + // merge the remaining meta defaults + $tags = array_merge($tags, $this->snippetData(array_diff_key($this->metaDefaults, array_flip($this->consumed)))); + } + + return $tags; + } + + /** + * Resolves the tag type from the meta array + */ + protected function resolveTag(string $tag): array + { + foreach (self::TAG_TYPE_MAP as $type) { + foreach ($type['tags'] as $regexOrString) { + // Check if the supplied tag is a regex or a normal tag name + if (Str::startsWith($regexOrString, '/') && Str::endsWith($regexOrString, '/') ? + Str::match($tag, $regexOrString) : $tag === $regexOrString + ) { + return $type; + } + } + } + + return [ + 'tag' => 'meta', + 'attributes' => [ + 'name' => 'name', + 'content' => 'content', + ] + ]; + } + + /** + * Magic method to get a meta value by calling the method name + */ + public function __call($name, $args = null): mixed + { + if (method_exists($this, $name)) { + return $this->$name($args); + } + + return $this->get($name); + } + + /** + * Get the meta value for a given key + */ + public function get(string $key, array $exclude = []): Field + { + $cascade = Seo::option('cascade'); + if (count(array_intersect(get_class_methods($this), $cascade)) !== count($cascade)) { + throw new InvalidArgumentException('[Kirby SEO] Invalid cascade method in config. Please check your options for `tobimori.seo.cascade`.'); + } + + // Track consumed keys, so we don't output legacy field values + $toBeConsumed = $key; + if ( + (array_key_exists($toBeConsumed, $this->metaDefaults) + || array_key_exists($toBeConsumed = $this->findTagForField($toBeConsumed), $this->metaDefaults)) + && !in_array($toBeConsumed, $this->consumed) + ) { + $this->consumed[] = $toBeConsumed; + } + + foreach (array_diff($cascade, $exclude) as $method) { + if ($field = $this->$method($key)) { + if ( + is_string($value = $field->value()) + && Str::contains($value, 'data-seo-template-variable') + ) { + $value = Str::unhtml($value); + return new Field($this->page, $key, $value); + } + + return $field; + } + } + + return new Field($this->page, $key, ''); + } + + /** + * Get the meta value for a given key from the page's fields + */ + protected function fields(string $key): Field|null + { + if (($field = $this->page->content($this->lang?->code())->get($key))) { + if (Str::contains($key, 'robots') && !Seo::option('robots.pageSettings')) { + return null; + } + + if ($field->isNotEmpty() && !A::has(self::DEFAULT_VALUES, $field->value())) { + return $field; + } + } + + return null; + } + + /** + * Maps Open Graph fields to Meta fields for fallbackFields + * cascade method + */ + public const FALLBACK_MAP = [ + 'ogTitle' => 'metaTitle', + 'ogDescription' => 'metaDescription', + 'ogTemplate' => 'metaTemplate', + ]; + + /** + * We only allow the following cascade methods for fallbacks, + * because we don't want to fallback to the config defaults for + * Meta fields, because we most likely already have those set + * for the Open Graph fields + */ + public const FALLBACK_CASCADE = [ + 'fields', + 'programmatic', + 'parent', + 'site' + ]; + + /** + * Get the meta value for a given key using the fallback fields + * defined above (usually Open Graph > Meta Fields) + */ + protected function fallbackFields(string $key): Field|null + { + if (array_key_exists($key, self::FALLBACK_MAP)) { + $fallback = self::FALLBACK_MAP[$key]; + $cascade = Seo::option('cascade'); + + foreach (array_intersect($cascade, self::FALLBACK_CASCADE) as $method) { + if ($field = $this->$method($fallback)) { + return $field; + } + } + } + + return null; + } + + protected function findTagForField(string $fieldName): string|null + { + return array_search($fieldName, $this->metaArray()); + } + + /** + * Get the meta value for a given key from the page's meta + * array, which can be set in the page's model metaDefaults method + */ + protected function programmatic(string $key): Field|null + { + if (!$this->metaDefaults) { + return null; + } + + // Check if the key (field name) is in the array syntax + if (array_key_exists($key, $this->metaDefaults)) { + $val = $this->metaDefaults[$key]; + } + + // If there is no programmatic value for the key, + // try looking it up in the meta array + // maybe it is a meta tag and not a field name? + if (!isset($val) && ($key = $this->findTagForField($key)) && array_key_exists($key, $this->metaDefaults)) { + $val = $this->metaDefaults[$key]; + } + + if (isset($val)) { + if (is_callable($val)) { + $val = $val($this->page); + } + + if (is_array($val)) { + $val = $val['content'] ?? $val['href'] ?? null; + + // Last sanity check, if the array syntax doesn't have a supported key + if ($val === null) { + // Remove the key from the consumed array, so it doesn't get filtered out + // (we can assume the entry is a custom meta tag that uses different attributes) + $this->consumed = array_filter($this->consumed, fn ($item) => $item !== $key); + return null; + } + } + + if (is_a($val, 'Kirby\Content\Field')) { + return new Field($this->page, $key, $val->value()); + } + + return new Field($this->page, $key, $val); + } + + return null; + } + + /** + * Get the meta value for a given key from the page's parent, + * if the page is allowed to inherit the value + */ + protected function parent(string $key): Field|null + { + if ($this->canInherit($key)) { + $parent = $this->page->parent(); + $parentMeta = new Meta($parent, $this->lang); + if ($value = $parentMeta->get($key)) { + return $value; + } + } + + return null; + } + + /** + * Get the meta value for a given key from the + * site's meta blueprint & content + */ + protected function site(string $key): Field|null + { + if (($site = $this->page->site()->content($this->lang?->code())->get($key)) && ($site->isNotEmpty() && !A::has(self::DEFAULT_VALUES, $site->value))) { + return $site; + } + + return null; + } + + /** + * Get the meta value for a given key from the + * config.php options + */ + protected function options(string $key): Field|null + { + if ($option = Seo::option("default.{$key}", args: [$this->page])) { + if (is_a($option, Field::class)) { + return $option; + } + + return new Field($this->page, $key, $option); + } + + return null; + } + + /** + * Checks if the page can inherit a meta value from its parent + */ + private function canInherit(string $key): bool + { + $parent = $this->page->parent(); + if (!$parent) { + return false; + } + + $inherit = $parent->metaInherit()->split(); + if (Str::contains($key, 'robots') && A::has($inherit, 'robots')) { + return true; + } + return A::has($inherit, $key); + } + + /** + * Applies the title template, and returns the correct title + */ + public function metaTitle() + { + $title = $this->get('metaTitle'); + $template = $this->get('metaTemplate'); + + $useTemplate = $this->page->useTitleTemplate(); + $useTemplate = $useTemplate->isEmpty() ? true : $useTemplate->toBool(); + + $string = $title->value(); + if ($useTemplate) { + $string = $this->page->toString( + $template, + ['title' => $title] + ); + } + + return new Field( + $this->page, + 'metaTitle', + $string + ); + } + + /** + * Applies the OG title template, and returns the OG Title + */ + public function ogTitle() + { + $title = $this->get('metaTitle'); + $template = $this->get('ogTemplate'); + + $useTemplate = $this->page->useOgTemplate(); + $useTemplate = $useTemplate->isEmpty() ? true : $useTemplate->toBool(); + + $string = $title->value(); + if ($useTemplate) { + $string = $this->page->toString( + $template, + ['title' => $title] + ); + } + + return new Field( + $this->page, + 'ogTitle', + $string + ); + } + + /** + * Gets the canonical url for the page + */ + public function canonicalUrl() + { + return $this->page->site()->canonicalFor($this->page->url()); + } + + /** + * Gets the date format for modified meta tags, based on the registered date handler + */ + public function dateFormat(): string + { + if ($custom = Seo::option('dateFormat')) { + return $custom; + } + + switch (option('date.handler')) { + case 'strftime': + return '%Y-%m-%d'; + case 'intl': + return 'yyyy-MM-dd'; + case 'date': + default: + return 'Y-m-d'; + } + } + + /** + * Get the pages' robots rules as string + */ + public function robots() + { + $robots = []; + foreach (Seo::option('robots.types') as $type) { + if (!$this->get('robots' . Str::ucfirst($type))->toBool()) { + $robots[] = 'no' . Str::lower($type); + } + } + + if (A::count($robots) === 0) { + $robots = ['all']; + } + + return A::join($robots, ','); + } + + /** + * Get the og:image thumb object + */ + public function ogImageThumb(): FileVersion|null + { + $field = $this->get('ogImage'); + + // Only process if we have a file object + if ($file = $field->toFile()) { + $cropOgImage = $this->get('cropOgImage')->toBool(); + + if ($cropOgImage) { + // Crop to 1200x630 + return $file->thumb([ + 'width' => 1200, + 'height' => 630, + 'crop' => true, + ]); + } else { + // Resize to max 1500px on the longest side + return $file->thumb([ + 'width' => 1500, + 'height' => 1500, + 'upscale' => false, + ]); + } + } + + // Return null if it's a custom URL or empty + return null; + } + + /** + * Get the og:image url + */ + public function ogImage(): string|null + { + if ($ogImage = $this->ogImageThumb()) { + return $ogImage->url(); + } + + $field = $this->get('ogImage'); + if ($field->isNotEmpty()) { + return $field->value(); + } + + return null; + } + + /** + * Helper method the get the current page from the URL path, + * for use in programmatic blueprints + */ + public static function currentPage(): Page|null + { + $path = App::instance()->request()->url()->toString(); + $matches = Str::match($path, "/pages\/([a-zA-Z0-9-_+]+)\/?/m"); + $segments = Str::split($matches[1], '+'); + + $page = App::instance()->site(); + foreach ($segments as $segment) { + if ($page = $page->findPageOrDraft($segment)) { + continue; + } + + return null; + } + + return $page; + } +} diff --git a/site/plugins/kirby-seo/classes/SchemaSingleton.php b/site/plugins/kirby-seo/classes/SchemaSingleton.php new file mode 100644 index 0000000..1e44c6a --- /dev/null +++ b/site/plugins/kirby-seo/classes/SchemaSingleton.php @@ -0,0 +1,37 @@ +id() ?? 'default'][$type])) { + self::$instances[$page?->id() ?? 'default'][$type] = Schema::{$type}(); + } + + return self::$instances[$page?->id() ?? 'default'][$type]; + } + + public static function getInstances(Page|null $page = null): array + { + if (!class_exists('Spatie\SchemaOrg\Schema')) { + return []; + } + + return self::$instances[$page?->id() ?? 'default'] ?? []; + } +} diff --git a/site/plugins/kirby-seo/classes/Seo.php b/site/plugins/kirby-seo/classes/Seo.php new file mode 100644 index 0000000..735189e --- /dev/null +++ b/site/plugins/kirby-seo/classes/Seo.php @@ -0,0 +1,29 @@ +version() . " (+https://plugins.andkindness.com/seo)"; + } + + /** + * Returns a plugin option + */ + public static function option(string $key, mixed $default = null, mixed $args = []): mixed + { + $option = App::instance()->option("tobimori.seo.{$key}", $default); + if (is_callable($option)) { + $option = $option(...$args); + } + + return $option; + } +} diff --git a/site/plugins/kirby-seo/classes/Sitemap/Sitemap.php b/site/plugins/kirby-seo/classes/Sitemap/Sitemap.php new file mode 100644 index 0000000..2d29c98 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Sitemap/Sitemap.php @@ -0,0 +1,87 @@ +key; + } + + public function loc(): string + { + return kirby()->site()->canonicalFor('sitemap-' . $this->key . '.xml'); + } + + public function lastmod(): string + { + $lastmod = 0; + foreach ($this as $url) { + $lastmod = max($lastmod, strtotime($url->lastmod())); + } + + if ($lastmod > 0) { + return date('c', $lastmod); + } + + return date('c'); + } + + public function createUrl(string $loc): SitemapUrl + { + $url = $this->makeUrl($loc); + $this->append($url); + return $url; + } + + public static function makeUrl(string $url): SitemapUrl + { + return new SitemapUrl($url); + } + + public function toDOMNode(DOMDocument $doc = new DOMDocument('1.0', 'UTF-8')) + { + $doc->formatOutput = true; + + $root = $doc->createElement('sitemap'); + foreach (['loc', 'lastmod'] as $key) { + $root->appendChild($doc->createElement($key, $this->$key())); + } + + return $root; + } + + public function toString(): string + { + $doc = new DOMDocument('1.0', 'UTF-8'); + $doc->formatOutput = true; + + $stylesheetUrl = kirby()->site()->canonicalFor("sitemap.xsl", true); + $doc->appendChild($doc->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $stylesheetUrl . '"')); + + $root = $doc->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'urlset'); + $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + + // version can be null when installing branches during development + if ($version = App::plugin('tobimori/seo')->version()) { + $root->setAttribute('seo-version', $version); + } + + foreach ($this as $url) { + $root->appendChild($url->toDOMNode($doc)); + } + + $doc->appendChild($root); + return $doc->saveXML(); + } +} diff --git a/site/plugins/kirby-seo/classes/Sitemap/SitemapIndex.php b/site/plugins/kirby-seo/classes/Sitemap/SitemapIndex.php new file mode 100644 index 0000000..7ced6a1 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Sitemap/SitemapIndex.php @@ -0,0 +1,101 @@ +make($key); + $this->append($sitemap); + return $sitemap; + } + + public static function make(string $key = 'pages'): Sitemap + { + return new Sitemap($key); + } + + public static function makeUrl(string $url): SitemapUrl + { + return new SitemapUrl($url); + } + + public function toString(): string + { + $doc = new DOMDocument('1.0', 'UTF-8'); + $doc->formatOutput = true; + + $stylesheetUrl = kirby()->site()->canonicalFor("sitemap.xsl", true); + $doc->appendChild($doc->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="' . $stylesheetUrl . '"')); + + $root = $doc->createElementNS('http://www.sitemaps.org/schemas/sitemap/0.9', 'sitemapindex'); + $root->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xhtml', 'http://www.w3.org/1999/xhtml'); + $root->setAttribute('seo-version', App::plugin('tobimori/seo')->version()); + $doc->appendChild($root); + + foreach ($this as $sitemap) { + $root->appendChild($sitemap->toDOMNode($doc)); + } + + return $doc->saveXML(); + } + + public function isValidIndex(?string $key = null): bool + { + if ($key === null) { + return $this->count() > 1; + } + + return !!$this->findBy('key', $key) && $this->count() > 1; + } + + public function generate(): void + { + $generator = option('tobimori.seo.sitemap.generator'); + if (is_callable($generator)) { + $generator($this); + } + } + + public function render(Page $page): string|null + { + // There always has to be at least one index, + // otherwise the sitemap will fail to render + if ($this->count() === 0) { + $this->generate(); + } + + if ($this->count() === 0) { + $this->create(); + } + + if (($index = $page->content()->get('index'))->isEmpty()) { + // If there is only one index, we do not need to render the index page + return $this->count() > 1 ? $this->toString() : $this->first()->toString(); + } + + $sitemap = $this->findBy('key', $index->value()); + if ($sitemap) { + return $sitemap->toString(); + } + + return null; + } +} diff --git a/site/plugins/kirby-seo/classes/Sitemap/SitemapUrl.php b/site/plugins/kirby-seo/classes/Sitemap/SitemapUrl.php new file mode 100644 index 0000000..1ee372f --- /dev/null +++ b/site/plugins/kirby-seo/classes/Sitemap/SitemapUrl.php @@ -0,0 +1,115 @@ +loc; + } + + $this->loc = $url; + return $this; + } + + public function lastmod(?string $lastmod = null): SitemapUrl|string + { + if ($lastmod === null) { + return $this->lastmod; + } + + $this->lastmod = date('c', $lastmod); + return $this; + } + + public function changefreq(?string $changefreq = null): SitemapUrl|string + { + if ($changefreq === null) { + return $this->changefreq; + } + + $this->changefreq = $changefreq; + return $this; + } + + public function priority(?string $priority = null): SitemapUrl|string + { + if ($priority === null) { + return $this->priority; + } + + $this->priority = $priority; + return $this; + } + + public function alternates(array $alternates = []): SitemapUrl|array + { + if (empty($alternates)) { + return $this->alternates; + } + + foreach ($alternates as $alternate) { + foreach (['href', 'hreflang'] as $key) { + if (!array_key_exists($key, $alternate)) { + new Exception("[Kirby SEO] The alternate link to '{$this->loc()} is missing the '{$key}' attribute"); + } + } + } + + + $this->alternates = $alternates; + return $this; + } + + public function toDOMNode(DOMDocument $doc = new DOMDocument('1.0', 'UTF-8')): DOMNode + { + $doc->formatOutput = true; + + $node = $doc->createElement('url'); + + foreach (array_diff_key(get_object_vars($this), array_flip(['alternates'])) as $key => $value) { + $node->appendChild($doc->createElement($key, $value)); + } + + if (!empty($this->alternates())) { + foreach ($this->alternates() as $alternate) { + $alternateNode = $doc->createElement('xhtml:link'); + foreach ($alternate as $key => $value) { + $alternateNode->setAttribute($key, $value); + } + + $node->appendChild($alternateNode); + } + } + + return $node; + } + + public function toString(): string + { + $doc = new DOMDocument('1.0', 'UTF-8'); + $doc->formatOutput = true; + + $node = $this->toDOMNode(); + $doc->appendChild($node); + + return $doc->saveXML($node); + } +} diff --git a/site/plugins/kirby-seo/composer.json b/site/plugins/kirby-seo/composer.json new file mode 100644 index 0000000..6b77d04 --- /dev/null +++ b/site/plugins/kirby-seo/composer.json @@ -0,0 +1,49 @@ +{ + "name": "tobimori/kirby-seo", + "description": "The default choice for SEO on Kirby: Implement technical SEO & Meta best practices with ease and provide an easy-to-use editor experience", + "type": "kirby-plugin", + "version": "2.0.0-alpha.12", + "license": "proprietary", + "homepage": "https://github.com/tobimori/kirby-seo#readme", + "authors": [ + { + "name": "Tobias Möritz", + "email": "tobias@moeritz.io" + } + ], + "autoload": { + "psr-4": { + "tobimori\\Seo\\": "classes" + } + }, + "minimum-stability": "RC", + "require": { + "php": ">=8.3.0", + "getkirby/composer-installer": "^1.2.1" + }, + "suggest": { + "tobimori/kirby-queues": "Enable background processing support", + "getkirby/cli": "Enable background processing support", + "spatie/schema-org": "Enable the Schema.org support" + }, + "require-dev": { + "getkirby/cli": "^1.8.0", + "tobimori/kirby-queues": "^1.0.0-beta.1", + "friendsofphp/php-cs-fixer": "^3.48", + "spatie/schema-org": "^3.23", + "getkirby/cms": "^5.0.0" + }, + "scripts": { + "dist": "composer install --no-dev --optimize-autoloader", + "fix": "php-cs-fixer fix" + }, + "config": { + "optimize-autoloader": true, + "allow-plugins": { + "getkirby/composer-installer": true + } + }, + "extra": { + "kirby-cms-path": false + } +} diff --git a/site/plugins/kirby-seo/config/areas.php b/site/plugins/kirby-seo/config/areas.php new file mode 100644 index 0000000..99bc0cb --- /dev/null +++ b/site/plugins/kirby-seo/config/areas.php @@ -0,0 +1,145 @@ + fn () => + [ + 'buttons' => [ + 'page.robots' => fn (Page $page) => new RobotsViewButton($page), + 'utm-share' => fn (ModelWithContent $model) => new UtmShareViewButton($model) + ], + 'drawers' => [ + 'gsc-data' => [ + 'pattern' => 'seo/gsc/data/(:all)', + 'load' => function (string $parent) { + $kirby = App::instance(); + $request = $kirby->request(); + $metric = $request->get('metric', 'clicks'); + $asc = (bool) $request->get('asc', in_array($metric, ['position', 'query']) ? 1 : 0); + $page = max(1, (int) $request->get('page', 1)); + $limit = max(1, min(100, (int) $request->get('limit', 20))); + + try { + $model = Find::parent(ltrim($parent, '/')); + } catch (\Exception $e) { + return ['component' => 'k-error-drawer', 'props' => ['message' => 'Model not found']]; + } + + $gsc = Seo::option('components.gsc'); + if (!$gsc::hasCredentials() || !$gsc::isConnected() || !$gsc::property()) { + return ['component' => 'k-error-drawer', 'props' => ['message' => 'GSC not connected']]; + } + + $title = I18n::translate('seo.sections.searchConsole.title'); + if ($model instanceof Page) { + $title .= ' · ' . $model->title()->value(); + } + + $data = $gsc::queryForModel($model, $metric, 25000, $asc); + $total = count($data); + $pageData = array_slice($data, ($page - 1) * $limit, $limit); + + // format numbers with locale + $locale = $kirby->panelLanguage(); + $number = new NumberFormatter($locale, NumberFormatter::DECIMAL); + $percent = new NumberFormatter($locale, NumberFormatter::PERCENT); + $percent->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 1); + $percent->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 1); + $decimal = new NumberFormatter($locale, NumberFormatter::DECIMAL); + $decimal->setAttribute(NumberFormatter::MIN_FRACTION_DIGITS, 1); + $decimal->setAttribute(NumberFormatter::MAX_FRACTION_DIGITS, 1); + + $rows = array_map(fn ($row) => [ + 'query' => $row['keys'][0], + 'clicks' => $number->format($row['clicks']), + 'impressions' => $number->format($row['impressions']), + 'ctr' => $percent->format($row['ctr']), + 'position' => $decimal->format($row['position']) + ], $pageData); + + return [ + 'component' => 'k-gsc-drawer', + 'props' => [ + 'title' => $title, + 'icon' => 'google', + 'parent' => $parent, + 'metric' => $metric, + 'sortAsc' => $asc, + 'page' => $page, + 'limit' => $limit, + 'total' => $total, + 'columns' => [ + 'query' => ['label' => I18n::translate('seo.sections.searchConsole.query'), 'width' => '1/2', 'mobile' => true], + 'clicks' => ['label' => I18n::translate('seo.sections.searchConsole.clicks'), 'width' => '1/8', 'align' => 'right'], + 'impressions' => ['label' => I18n::translate('seo.sections.searchConsole.impressions'), 'width' => '1/8', 'align' => 'right'], + 'ctr' => ['label' => I18n::translate('seo.sections.searchConsole.ctr'), 'width' => '1/8', 'align' => 'right'], + 'position' => ['label' => I18n::translate('seo.sections.searchConsole.position'), 'width' => '1/8', 'align' => 'right', 'mobile' => true] + ], + 'rows' => $rows + ] + ]; + } + ] + ], + 'dialogs' => [ + 'utm-share' => [ + 'pattern' => 'seo/utm-share/(:all)', + 'controller' => UtmShareDialog::class + ], + 'gsc-select-property' => [ + 'pattern' => 'seo/gsc/select-property', + 'load' => function () { + $siteUrl = App::instance()->site()->url(); + $gsc = Seo::option('components.gsc'); + + $properties = $gsc::listProperties(); + $options = array_map(fn ($p) => [ + 'value' => $p['siteUrl'], + 'text' => str_starts_with($p['siteUrl'], 'sc-domain:') + ? substr($p['siteUrl'], 10) . ' (' . I18n::translate('seo.sections.searchConsole.scDomain') . ')' + : $p['siteUrl'] + ], $properties); + + $currentProperty = $gsc::property(); + $defaultProperty = $currentProperty ?? $gsc::findMatchingProperty($siteUrl); + + return [ + 'component' => 'k-form-dialog', + 'props' => [ + 'fields' => [ + 'property' => [ + 'label' => I18n::translate('seo.sections.searchConsole.selectPropertyLabel'), + 'type' => 'select', + 'required' => true, + 'options' => $options, + 'empty' => false + ] + ], + 'submitButton' => I18n::translate('select'), + 'value' => [ + 'property' => $defaultProperty + ] + ] + ]; + }, + 'submit' => function () { + $property = App::instance()->request()->get('property'); + Seo::option('components.gsc')::setProperty($property); + + return [ + 'event' => 'gsc.propertySelected' + ]; + } + ] + ] + ] +]; diff --git a/site/plugins/kirby-seo/config/fields.php b/site/plugins/kirby-seo/config/fields.php new file mode 100644 index 0000000..d9accf7 --- /dev/null +++ b/site/plugins/kirby-seo/config/fields.php @@ -0,0 +1,130 @@ + [ + 'extends' => 'writer', + 'props' => [ + /** + * Enables/disables the character counter in the top right corner + */ + 'ai' => function (string|bool $ai = false) { + if (!Seo::option('components.ai')::enabled()) { + return false; + } + + // check ai permission @see index.php L31 + if (App::instance()->user()->role()->permissions()->for('tobimori.seo', 'ai') === false) { + return false; + } + + return $ai; + }, + + // reset defaults + 'counter' => fn (bool $counter = false) => $counter, // we have to disable the counter because its at the same place as our ai button + 'inline' => fn (bool $inline = true) => $inline, + 'marks' => fn (array|bool|null $marks = false) => $marks, + 'nodes' => fn (array|bool|null $nodes = false) => $nodes, + ], + 'api' => fn () => [ + [ + 'pattern' => 'ai/stream', + 'method' => 'POST', + 'action' => function () { + $kirby = $this->kirby(); + $component = Seo::option('components.ai'); + + if (!$component::enabled()) { + return Response::json([ + 'status' => 'error', + 'message' => t('seo.ai.error.disabled') + ], 404); + } + + if ($kirby->user()->role()->permissions()->for('tobimori.seo', 'ai') === false) { + return Response::json([ + 'status' => 'error', + 'message' => t('seo.ai.error.permission') + ], 404); + } + + $data = $kirby->request()->body()->data(); + $lang = $kirby->api()->language(); + + // for site, use homepage + $model = $this->field()->model(); + $page = $model instanceof Page ? $model : $model->homePage(); + $kirby->site()->visit($page, $lang); + if ($lang) { + $kirby->setCurrentLanguage($lang); + } + + // inject data in snippets / rendering process + $kirby->data = [ // TODO: check if we want to access the draft / edited version for $page + 'page' => $page, + 'site' => $kirby->site(), + 'kirby' => $kirby + ]; + + // begin streaming thingy + ignore_user_abort(true); + @set_time_limit(0); + + while (ob_get_level() > 0) { + ob_end_flush(); + } + + header('Content-Type: text/event-stream'); + header('Cache-Control: no-cache'); + header('Connection: keep-alive'); + header('X-Accel-Buffering: no'); + echo ":ok\n\n"; + flush(); + + $send = static function (array $event): void { + echo 'data: ' . json_encode( + $event, + JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES + ) . "\n\n"; + + if (ob_get_level() > 0) { + ob_flush(); + } + + flush(); + }; + + try { + foreach ( + $component::streamTask($this->field()->ai(), [ + 'instructions' => $data['instructions'] ?? null, + 'edit' => $data['edit'] ?? null + ]) as $chunk + ) { + $send([ + 'type' => $chunk->type, + 'text' => $chunk->text, + 'payload' => $chunk->payload, + ]); + } + } catch (\Throwable $exception) { + $send([ + 'type' => 'error', + 'payload' => [ + 'message' => $exception->getMessage(), + ], + ]); + } + + exit(); + } + ] + ] + ] +]; diff --git a/site/plugins/kirby-seo/config/hooks.php b/site/plugins/kirby-seo/config/hooks.php new file mode 100644 index 0000000..ab002d3 --- /dev/null +++ b/site/plugins/kirby-seo/config/hooks.php @@ -0,0 +1,64 @@ + 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()); + } + }, +]; diff --git a/site/plugins/kirby-seo/config/options.php b/site/plugins/kirby-seo/config/options.php new file mode 100644 index 0000000..6962952 --- /dev/null +++ b/site/plugins/kirby-seo/config/options.php @@ -0,0 +1,112 @@ + [ + 'meta' => Meta::class, + 'ai' => Ai::class, + 'indexnow' => IndexNow::class, + 'schema' => SchemaSingleton::class, + 'gsc' => GoogleSearchConsole::class, + ], + 'cache.searchConsole' => true, + 'cache.indexnow' => true, + 'cascade' => [ + 'fields', + 'programmatic', + // 'fallbackFields', // fallback to meta fields for open graph fields + 'parent', + 'site', + 'options' + ], + 'default' => [ // default field values for metadata, format is [field => value] + 'metaTitle' => fn (Page $page) => $page->title(), + 'metaTemplate' => '{{ title }} - {{ site.title }}', + 'ogTemplate' => '{{ title }}', + 'ogSiteName' => fn (Page $page) => $page->site()->title(), + 'ogType' => 'website', + 'ogDescription' => fn (Page $page) => $page->metadata()->metaDescription(), + 'cropOgImage' => true, + 'locale' => fn (Page $page) => $page->kirby()->language()?->locale(LC_ALL) ?? Seo::option('locale', 'en_US'), + // default for robots: noIndex if global index configuration is set, otherwise fall back to page status + 'robotsIndex' => function (Page $page) { + $index = Seo::option('robots.index'); + if (!$index) { + return false; + } + + return Seo::option('robots.followPageStatus') ? $page->isListed() : true; + }, + 'robotsFollow' => fn (Page $page) => $page->kirby()->option('tobimori.seo.default.robotsIndex')($page), + 'robotsArchive' => fn (Page $page) => $page->kirby()->option('tobimori.seo.default.robotsIndex')($page), + 'robotsImageindex' => fn (Page $page) => $page->kirby()->option('tobimori.seo.default.robotsIndex')($page), + 'robotsSnippet' => fn (Page $page) => $page->kirby()->option('tobimori.seo.default.robotsIndex')($page), + ], + 'socialMedia' => [ // default fields for social media links, format is [field => placeholder] + 'twitter' => 'https://twitter.com/my-company', + 'facebook' => 'https://facebook.com/my-company', + 'instagram' => 'https://instagram.com/my-company', + 'youtube' => 'https://youtube.com/channel/my-company', + 'linkedin' => 'https://linkedin.com/company/my-company', + 'bluesky' => 'https://bsky.app/profile/example.bsky.social', + 'mastodon' => 'https://mastodon.social/@example' + ], + 'previews' => [ + 'google', + 'facebook', + 'slack' + ], + 'robots' => [ + 'enabled' => true, // whether robots handling should be done by the plugin + + // @deprecated - please use robots.enabled + 'active' => fn () => Seo::option('sitemap.enabled'), + 'followPageStatus' => true, // should unlisted pages be noindex by default? + 'pageSettings' => true, // whether to have robots settings on each page + 'index' => fn () => !App::instance()->option('debug'), // default site-wide robots setting + 'sitemap' => null, // sets sitemap url, will be replaced by plugin sitemap in the future + 'content' => [], // custom robots content + 'types' => ['index', 'follow', 'archive', 'imageindex', 'snippet'] // available robots types + ], + 'sitemap' => [ + 'enabled' => true, + // @deprecated - please use sitemap.enabled + 'active' => fn () => Seo::option('sitemap.enabled'), + 'redirect' => true, // redirect /sitemap to /sitemap.xml + 'locale' => 'en', + 'generator' => require __DIR__ . '/options/sitemap.php', + 'changefreq' => 'weekly', + 'groupByTemplate' => false, + 'excludeTemplates' => ['error'], + 'priority' => fn (Page $page) => number_format(($page->isHomePage()) ? 1 : max(1 - 0.2 * $page->depth(), 0.2), 1), + ], + 'files' => [ + 'parent' => null, + 'template' => null, + ], + 'canonical' => [ + 'base' => null, // base url for canonical links + 'trailingSlash' => false, // whether to add trailing slashes to canonical URLs (except for files) + ], + 'ai' => require __DIR__ . '/options/ai.php', + 'indexnow' => require __DIR__ . '/options/indexnow.php', + 'searchConsole' => [ + 'enabled' => true, + 'credentials' => null, + 'tokenPath' => fn () => App::instance()->root('config') . '/.gsc-tokens.json' + ], + 'generateSchema' => true, // whether to generate default schema.org data + 'locale' => 'en_US', // default locale, used for single-language sites + 'dateFormat' => null, // custom date format +]; diff --git a/site/plugins/kirby-seo/config/options/ai.php b/site/plugins/kirby-seo/config/options/ai.php new file mode 100644 index 0000000..2e290b6 --- /dev/null +++ b/site/plugins/kirby-seo/config/options/ai.php @@ -0,0 +1,32 @@ + true, + 'provider' => 'openai', + 'providers' => [ + 'openai' => [ + 'driver' => OpenAi::class, + 'config' => [ + 'apiKey' => '', // needs to be defined + ], + ], + 'anthropic' => [ + 'driver' => Anthropic::class, + 'config' => [ + 'apiKey' => '', // needs to be defined + ], + ], + 'openrouter' => [ + 'driver' => OpenAi::class, + 'config' => [ + 'apiKey' => '', // needs to be defined + 'model' => 'openai/gpt-5-nano', + 'endpoint' => 'https://openrouter.ai/api/v1/responses', + ], + ], + ], +]; diff --git a/site/plugins/kirby-seo/config/options/indexnow.php b/site/plugins/kirby-seo/config/options/indexnow.php new file mode 100644 index 0000000..5e0d151 --- /dev/null +++ b/site/plugins/kirby-seo/config/options/indexnow.php @@ -0,0 +1,29 @@ + true, + 'searchEngine' => 'https://api.indexnow.org', // one will propagate to all others. so this is fine @see https://www.indexnow.org/faq + 'rules' => [ + // by default, only the current page is requested to be indexed (if indexable: robots allow + listed status) + // however you might want to index other pages as well. for example, the 'blog overview' page should always be reindexed when a new 'blog post' is indexed + // + // syntax: 'match pattern' => ['invalidation rules'] + // + // match patterns: + // - '/blog/*' - url pattern (glob or regex) + // - 'article' - template name + // - '*' - wildcard, matches all pages + // + // invalidation rules: + // - 'parent' => true (direct parent) or number (levels up) + // - 'children' => true (all descendants) or number (depth limit) + // - 'siblings' => true (all siblings at same level) + // - 'urls' => ['/shop', '/'] (specific urls to invalidate) + // - 'templates' => ['category', 'shop'] (invalidate all pages with these templates) + // + // examples: + // '/blog/*' => ['parent' => true], + // 'article' => ['parent' => 2, 'urls' => ['/blog', '/']], + // 'product' => ['parent' => true, 'siblings' => true, 'templates' => ['category']], + ], +]; diff --git a/site/plugins/kirby-seo/config/options/sitemap.php b/site/plugins/kirby-seo/config/options/sitemap.php new file mode 100644 index 0000000..cef6704 --- /dev/null +++ b/site/plugins/kirby-seo/config/options/sitemap.php @@ -0,0 +1,55 @@ +index()->filter(fn ($page) => $page->metadata()->robotsIndex()->toBool() && !in_array($page->intendedTemplate()->name(), $exclude)); + + if ($group = option('tobimori.seo.sitemap.groupByTemplate')) { + $pages = $pages->group('intendedTemplate'); + } + + if (is_a($pages->first(), 'Kirby\Cms\Page')) { + $pages = $pages->group(fn () => 'pages'); + } + + foreach ($pages as $group) { + $index = $sitemap->create($group ? $group->first()->intendedTemplate()->name() : 'pages'); + + foreach ($group as $page) { + $url = $index->createUrl($page->metadata()->canonicalUrl()) + ->lastmod($page->modified() ?? (int)(date('c'))) + ->changefreq(is_callable($changefreq = option('tobimori.seo.sitemap.changefreq')) ? $changefreq($page) : $changefreq) + ->priority(is_callable($priority = option('tobimori.seo.sitemap.priority')) ? $priority($page) : $priority); + + if (kirby()->languages()->count() > 1 && kirby()->language() !== null) { + $alternates = []; + foreach (kirby()->languages() as $language) { + // only if this language is translated for this page and exists + if ($page->translation($language->code())->exists()) { + /* + * Specification: "lists every alternate version of the page, including itself." + * https://developers.google.com/search/docs/specialty/international/localized-versions#sitemap + */ + $alternates[] = + [ + 'hreflang' => Meta::toBCP47($language), + 'href' => $page->url($language->code()), + ]; + } + } + + // add x-default + $alternates[] = + [ + 'hreflang' => 'x-default', + 'href' => $page->indexUrl(), + ]; + + $url->alternates($alternates); + } + } + } +}; diff --git a/site/plugins/kirby-seo/config/page-methods.php b/site/plugins/kirby-seo/config/page-methods.php new file mode 100644 index 0000000..5198080 --- /dev/null +++ b/site/plugins/kirby-seo/config/page-methods.php @@ -0,0 +1,40 @@ + fn ($type) => Seo::option('components.schema')::getInstance($type, $this), + 'schemas' => fn () => Seo::option('components.schema')::getInstances($this), + 'metadata' => fn (?Language $lang = null) => new (Seo::option('components.meta'))($this, $lang), + 'robots' => fn (?Language $lang = null) => $this->metadata($lang)->robots(), + 'indexUrl' => function () { + // Google: "fallback page for unmatched languages, especially on language/country selectors or auto-redirecting home pages." + // https://developers.google.com/search/docs/specialty/international/localized-versions#all-method-guidelines + + // returns the index URL of the site, e.g. https://example.com/ + $kirbyUrl = $this->kirby()->url('index'); + + $defaultLang = $this->kirby()->defaultLanguage()?->code(); + // returns the site URL, e.g. https://example.com/en + // we have to request the default language so we don't get localized slugs + $siteUrl = $this->site()->url($defaultLang); + + // returns the full URL of the current page in the default language, e.g. https://example.com/en/about + // again, request default language otherwise there is a mismatch in language prefix between the site URL and the current page URL + $thisUrl = $this->url($defaultLang); + + // remove the part form the URL that is specific to the 'site' + // this is usually the language code prefix + // https://example.com/en/ + https://example.com/en/about -> https://example.com/about + if (strpos($siteUrl, $kirbyUrl) === 0 && strlen($siteUrl) > strlen($kirbyUrl)) { + if (strpos($thisUrl, $siteUrl) === 0) { + $pathAfterSite = substr($thisUrl, strlen($siteUrl)); + return "{$kirbyUrl}{$pathAfterSite}"; + } + } + + return $thisUrl; + }, +]; diff --git a/site/plugins/kirby-seo/config/routes.php b/site/plugins/kirby-seo/config/routes.php new file mode 100644 index 0000000..280a433 --- /dev/null +++ b/site/plugins/kirby-seo/config/routes.php @@ -0,0 +1,281 @@ + 'indexnow-(:any).txt', + 'method' => 'GET', + 'action' => function (string $key) { + if (Seo::option('indexnow.enabled') && Seo::option('components.indexnow')::verifyKey($key)) { + return new Response($key, 'text/plain', 200); + } + + $this->next(); + } + ], + + [ + 'pattern' => 'robots.txt', + 'method' => 'GET|HEAD', + 'action' => function () { + if (Seo::option('robots.active')) { + $content = snippet('seo/robots.txt', [], true); + return new Response($content, 'text/plain', 200); + } + + $this->next(); + } + ], + [ + 'pattern' => 'robots.txt', + 'method' => 'OPTIONS', + 'action' => function () { + if (Seo::option('robots.active')) { + return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + [ + 'pattern' => 'robots.txt', + 'method' => 'ALL', + 'action' => function () { + if (Seo::option('robots.active')) { + return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + + [ + 'pattern' => 'sitemap', + 'method' => 'GET|HEAD', + 'action' => function () { + if (!Seo::option('sitemap.redirect') || !Seo::option('sitemap.active')) { + $this->next(); + } + + go('/sitemap.xml'); + } + ], + [ + 'pattern' => 'sitemap', + 'method' => 'OPTIONS', + 'action' => function () { + if (Seo::option('sitemap.active')) { + return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + [ + 'pattern' => 'sitemap', + 'method' => 'ALL', + 'action' => function () { + if (Seo::option('sitemap.active')) { + return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + + [ + 'pattern' => 'sitemap.xsl', + 'method' => 'GET', + 'action' => function () { + if (!Seo::option('sitemap.active')) { + $this->next(); + } + + kirby()->response()->type('text/xsl'); + + $lang = Seo::option('sitemap.locale', 'en'); + kirby()->setCurrentTranslation($lang); + + return Page::factory([ + 'slug' => 'sitemap', + 'template' => 'sitemap', + 'model' => 'sitemap', + 'content' => [ + 'title' => t('sitemap'), + ], + ])->render(contentType: 'xsl'); + } + ], + [ + 'pattern' => 'sitemap.xsl', + 'method' => 'OPTIONS', + 'action' => function () { + if (Seo::option('sitemap.active')) { + return new Response('', 'text/plain', 204, ['Allow' => 'GET']); + } + + $this->next(); + } + ], + [ + 'pattern' => 'sitemap.xsl', + 'method' => 'ALL', + 'action' => function () { + if (Seo::option('sitemap.active')) { + return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET']); + } + + $this->next(); + } + ], + + [ + 'pattern' => 'sitemap.xml', + 'method' => 'GET|HEAD', + 'action' => function () { + if (!Seo::option('sitemap.active', true)) { + $this->next(); + } + + SitemapIndex::instance()->generate(); + kirby()->response()->type('text/xml'); + return Page::factory([ + 'slug' => 'sitemap', + 'template' => 'sitemap', + 'model' => 'sitemap', + 'content' => [ + 'title' => t('sitemap'), + 'index' => null, + ], + ])->render(contentType: 'xml'); + } + ], + [ + 'pattern' => 'sitemap.xml', + 'method' => 'OPTIONS', + 'action' => function () { + if (Seo::option('sitemap.active', true)) { + return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + [ + 'pattern' => 'sitemap.xml', + 'method' => 'ALL', + 'action' => function () { + if (Seo::option('sitemap.active', true)) { + return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + + [ + 'pattern' => 'sitemap-(:any).xml', + 'method' => 'GET|HEAD', + 'action' => function (string $index) { + if (!Seo::option('sitemap.active', true)) { + $this->next(); + } + + SitemapIndex::instance()->generate(); + if (!SitemapIndex::instance()->isValidIndex($index)) { + $this->next(); + } + + kirby()->response()->type('text/xml'); + return Page::factory([ + 'slug' => "sitemap-{$index}", + 'template' => 'sitemap', + 'model' => 'sitemap', + 'content' => [ + 'title' => t('sitemap'), + 'index' => $index, + ], + ])->render(contentType: 'xml'); + } + ], + [ + 'pattern' => 'sitemap-(:any).xml', + 'method' => 'OPTIONS', + 'action' => function () { + if (Seo::option('sitemap.active')) { + return new Response('', 'text/plain', 204, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + [ + 'pattern' => 'sitemap-(:any).xml', + 'method' => 'ALL', + 'action' => function () { + if (Seo::option('sitemap.active')) { + return new Response('Method Not Allowed', 'text/plain', 405, ['Allow' => 'GET, HEAD']); + } + + $this->next(); + } + ], + + // Google Search Console OAuth + [ + 'pattern' => '__seo/gsc/auth', + 'method' => 'GET', + 'action' => function () { + $kirby = App::instance(); + if (!$kirby->user() || !Seo::option('searchConsole.enabled') || !Seo::option('components.gsc')::hasCredentials()) { + go($kirby->site()->panel()->url()); + } + + $return = $kirby->request()->get('return') ?? $kirby->site()->panel()->url(); + $state = base64_encode(Json::encode([ + 'csrf' => bin2hex(random_bytes(16)), + 'return' => $return + ])); + + $redirectUri = rtrim($kirby->url(), '/') . '/__seo/gsc/callback'; + go(Seo::option('components.gsc')::authUrl($redirectUri, $state)); + } + ], + [ + 'pattern' => '__seo/gsc/callback', + 'method' => 'GET', + 'action' => function () { + $kirby = App::instance(); + if (!$kirby->user()) { + go($kirby->site()->panel()->url()); + } + + $request = $kirby->request(); + $state = Json::decode(base64_decode($request->get('state'))); + if (!$state || empty($state['csrf'])) { + throw new \Exception('Invalid OAuth state'); + } + + if ($error = $request->get('error')) { + throw new \Exception("OAuth error: {$error}"); + } + + if (!($code = $request->get('code'))) { + throw new \Exception('No authorization code received'); + } + + $redirectUri = rtrim($kirby->url(), '/') . '/__seo/gsc/callback'; + Seo::option('components.gsc')::exchangeCode($code, $redirectUri); + + // redirect back to where the user came from + $return = $state['return'] ?? $kirby->site()->panel()->url(); + go($return); + } + ], +]; diff --git a/site/plugins/kirby-seo/config/sections.php b/site/plugins/kirby-seo/config/sections.php new file mode 100644 index 0000000..ea4ddb8 --- /dev/null +++ b/site/plugins/kirby-seo/config/sections.php @@ -0,0 +1,134 @@ + [ + 'mixins' => ['headline'], + 'computed' => [ + 'options' => fn () => A::map(option('tobimori.seo.previews'), fn ($item) => [ + 'value' => $item, + 'text' => t("seo.sections.preview.{$item}") + ]), + 'meta' => function () { + $model = $this->model(); + + if ($model instanceof Site || $model instanceof Page) { + // clone the model with the content from the changes version + $changesVersion = $model->version('changes'); + if ($changesVersion->exists('current')) { + $model = $model->clone(['content' => $changesVersion->content()->toArray()]); + } + + // if it's a site, fall back to the home page for preview data + $model = $model instanceof Site ? $model->homePage() : $model; + if (!$model) { + return null; + } + + $meta = $model->metadata(); + return [ + 'page' => $model->slug(), + 'url' => $model->url(), + 'pageTitle' => Str::unhtml($model->title()->value()), + 'title' => Str::unhtml($meta->metaTitle()->value()), + 'description' => Str::unhtml($meta->metaDescription()->value()), + 'ogSiteName' => Str::unhtml($meta->ogSiteName()->value()), + 'ogTitle' => Str::unhtml($meta->ogTitle()->value()), + 'ogDescription' => Str::unhtml($meta->ogDescription()->value()), + 'ogImage' => $meta->ogImage(), + 'cropOgImage' => $meta->cropOgImage()->toBool(), + 'panelUrl' => method_exists($model, 'panel') ? "{$model->panel()?->url()}?tab=seo" : null, + ]; + } + + return null; + } + ] + ], + 'heading-structure' => [ + 'mixins' => ['headline'], + 'computed' => [ + 'data' => function () { + $model = $this->model(); + if (!($model instanceof Page)) { + // only works for pages (not site, files, etc.) + return []; + } + + // In Kirby 5, use the changes version if it exists + // clone the model with the content from the changes version + $changesVersion = $model->version('changes'); + if ($changesVersion->exists('current')) { + $model = $model->clone(['content' => $changesVersion->content()->toArray()]); + } + + // Render the page + $page = $model->render(); + $dom = new DOMDocument(); + $dom->loadHTML(htmlspecialchars_decode(mb_convert_encoding(htmlentities($page, ENT_COMPAT, 'UTF-8'), 'ISO-8859-1', 'UTF-8'), ENT_QUOTES), libxml_use_internal_errors(true)); + + $xpath = new DOMXPath($dom); + $headings = $xpath->query('//h1|//h2|//h3|//h4|//h5|//h6'); + $data = []; + + foreach ($headings as $heading) { + $data[] = [ + 'level' => (int)str_replace('h', '', $heading->nodeName), + 'text' => $heading->textContent, + ]; + } + + return $data; + } + ] + ], + 'seo-search-console' => [ + 'mixins' => ['headline'], + 'computed' => [ + 'status' => function () { + if (!Seo::option('components.gsc')::hasCredentials()) { + return 'NO_CREDENTIALS'; + } + + if (!Seo::option('components.gsc')::isConnected()) { + return 'NOT_CONNECTED'; + } + + if (!Seo::option('components.gsc')::property()) { + return 'SELECT_PROPERTY'; + } + + return 'CONNECTED'; + }, + 'property' => fn () => Seo::option('components.gsc')::property(), + 'pageUrl' => function () { + $model = $this->model(); + if ($model instanceof Page) { + return '/' . $model->uri(); + } + return null; + }, + 'data' => function () { + $gsc = Seo::option('components.gsc'); + if (!$gsc::hasCredentials() || !$gsc::isConnected() || !$gsc::property()) { + return []; + } + + $metric = kirby()->request()->get('metric', 'clicks'); + $limit = (int) kirby()->request()->get('limit', 10); + $asc = in_array($metric, ['position', 'query']); + + try { + return $gsc::queryForModel($this->model(), $metric, $limit, $asc); + } catch (\Exception $e) { + return []; + } + } + ] + ] +]; diff --git a/site/plugins/kirby-seo/config/site-methods.php b/site/plugins/kirby-seo/config/site-methods.php new file mode 100644 index 0000000..cdeb364 --- /dev/null +++ b/site/plugins/kirby-seo/config/site-methods.php @@ -0,0 +1,48 @@ + fn ($type) => Seo::option('components.schema')::getInstance($type), + 'schemas' => fn () => Seo::option('components.schema')::getInstances(), + 'lang' => fn () => Seo::option('components.meta')::normalizeLocale(Seo::option('default.locale', args: [$this->homePage()]), '-'), + 'canonicalFor' => function (string $url, bool $useRootUrl = false) { + // Determine the base URL + $base = Seo::option('canonical.base', Seo::option('canonicalBase')); + if (!$base) { + // If useRootUrl is true or this is a multilang site requesting root URL, use kirby()->url() + if ($useRootUrl && kirby()->multilang()) { + $base = kirby()->url(); + } else { + $base = $this->url(); + } + } + + if (Str::startsWith($url, $base)) { + $canonicalUrl = $url; + } else { + $path = Url::path($url); + $canonicalUrl = url($base . '/' . $path); + } + + $trailingSlash = Seo::option('canonical.trailingSlash', false); + if ($trailingSlash) { + // check if URL has a file extension (like .xml, .jpg, .pdf, etc.) + $path = parse_url($canonicalUrl, PHP_URL_PATH) ?? ''; + $pathInfo = pathinfo($path); + $hasExtension = !empty($pathInfo['extension'] ?? null); + + // Only add trailing slash if: + // - URL doesn't already have one + // - URL doesn't have a file extension + // - URL isn't just the base domain + if (!Str::endsWith($canonicalUrl, '/') && !$hasExtension && $canonicalUrl !== $base) { + $canonicalUrl .= '/'; + } + } + + return $canonicalUrl; + } +]; diff --git a/site/plugins/kirby-seo/index.css b/site/plugins/kirby-seo/index.css new file mode 100644 index 0000000..7f1e52e --- /dev/null +++ b/site/plugins/kirby-seo/index.css @@ -0,0 +1 @@ +.k-seo-template-variable{color:light-dark(var(--theme-color-text),var(--theme-color-back));background:color-mix(in srgb,var(--theme-color-back) 25%,var(--input-color-back));border-radius:var(--button-rounded);display:inline-block;font-weight:var(--font-semi);height:var(--text-line-height) em;line-height:var(--text-line-height) em;padding-inline:.5rem;white-space:nowrap;-webkit-user-select:none;user-select:none;vertical-align:baseline}.k-field-type-seo-writer img.ProseMirror-separator{display:inline-block;width:0;height:0;margin:0;padding:0;border:0;overflow:hidden}.k-field-type-seo-writer br.ProseMirror-trailingBreak{display:none}.k-field-type-seo-writer .k-writer-input .k-toolbar-button{padding-inline:var(--spacing-5);--button-width: auto;flex-basis:max-content}.k-field-type-seo-writer .k-writer-input .k-toolbar-button:after{content:attr(title)}.k-field-type-seo-writer .k-writer-input .k-toolbar-button:not(:first-child){border-left:1px solid var(--toolbar-border)}.k-seo-utm-share-dialog__close{position:absolute;top:var(--spacing-2);right:var(--spacing-2);z-index:1}.k-seo-utm-share-dialog__url-wrapper{margin-bottom:var(--spacing-6)}.k-seo-utm-share-dialog__section-label{margin-bottom:var(--spacing-2)}.k-seo-utm-share-dialog__url{padding-right:var(--spacing-1)}.k-seo-utm-share-dialog__copy{--button-height: calc(var(--input-height) - var(--spacing-2));--button-rounded: var(--rounded-sm);flex-shrink:0}.k-seo-utm-share-dialog__params{display:flex;flex-direction:column;gap:var(--spacing-2)}.k-seo-utm-share-dialog__row{display:flex;align-items:center;background:light-dark(var(--color-gray-100),var(--color-gray-900));border:1px solid var(--color-border);border-radius:var(--rounded)}.k-seo-utm-share-dialog__row .k-input,.k-seo-utm-share-dialog__row .k-string-input{border-top-left-radius:0;border-bottom-left-radius:0}.k-seo-utm-share-dialog__row .k-input{--input-color-back: light-dark(var(--color-white), var(--color-gray-850))}.k-seo-utm-share-dialog__label{display:flex;align-items:center;gap:var(--spacing-2);width:7rem;flex-shrink:0;padding:var(--input-padding);font-size:var(--text-sm);color:var(--color-text)}.k-seo-utm-share-dialog__label .k-icon{color:var(--color-text-dimmed)}.k-seo-utm-share-dialog__input{flex:1}.k-gsc-drawer .k-table th{cursor:pointer}.k-gsc-drawer .k-table th:hover{background:light-dark(var(--color-gray-200),var(--color-gray-700))}.k-gsc-drawer .k-table th>span{display:flex;align-items:center;justify-content:space-between;width:100%}.k-heading-structure__label{display:flex;align-items:center;justify-content:flex-start;gap:var(--spacing-2)}.k-heading-structure__label>.k-icon{color:var(--color-gray-700)}.k-heading-structure__label>.k-loader{margin-left:auto;color:var(--color-gray-700)}.k-heading-structure__notice{margin-top:var(--spacing-2);display:flex;align-items:flex-start}.k-heading-structure__notice>.k-icon{margin-top:.125rem;margin-right:var(--spacing-1);color:var(--color-red)}.k-heading-structure__list{overflow:hidden}.k-heading-structure__item{position:relative;background:var(--theme-color-back);padding-block:var(--spacing-px);display:flex}.k-heading-structure__item.is-invalid{color:var(--color-red)}.k-heading-structure__item__level{font-family:var(--font-mono);font-weight:700;margin-right:var(--spacing-2)}.k-heading-structure__item__text{white-space:nowrap;text-overflow:ellipsis;overflow:hidden}.k-heading-structure__item.level-2{margin-left:0;padding-left:1.6rem}.k-heading-structure__item.level-2:before{content:"";position:absolute;top:calc(50% - .0625rem);left:.4rem;width:.8rem;height:.125rem;background-color:currentColor}.k-heading-structure__item.level-2:after{content:"";position:absolute;bottom:calc(50% - .0625rem);left:.4rem;height:9999px;width:.125rem;background-color:currentColor}.k-heading-structure__item.level-3{margin-left:1.6rem;padding-left:1.6rem}.k-heading-structure__item.level-3:before{content:"";position:absolute;top:calc(50% - .0625rem);left:.4rem;width:.8rem;height:.125rem;background-color:currentColor}.k-heading-structure__item.level-3:after{content:"";position:absolute;bottom:calc(50% - .0625rem);left:.4rem;height:9999px;width:.125rem;background-color:currentColor}.k-heading-structure__item.level-4{margin-left:3.2rem;padding-left:1.6rem}.k-heading-structure__item.level-4:before{content:"";position:absolute;top:calc(50% - .0625rem);left:.4rem;width:.8rem;height:.125rem;background-color:currentColor}.k-heading-structure__item.level-4:after{content:"";position:absolute;bottom:calc(50% - .0625rem);left:.4rem;height:9999px;width:.125rem;background-color:currentColor}.k-heading-structure__item.level-5{margin-left:4.8rem;padding-left:1.6rem}.k-heading-structure__item.level-5:before{content:"";position:absolute;top:calc(50% - .0625rem);left:.4rem;width:.8rem;height:.125rem;background-color:currentColor}.k-heading-structure__item.level-5:after{content:"";position:absolute;bottom:calc(50% - .0625rem);left:.4rem;height:9999px;width:.125rem;background-color:currentColor}.k-heading-structure__item.level-6{margin-left:6.4rem;padding-left:1.6rem}.k-heading-structure__item.level-6:before{content:"";position:absolute;top:calc(50% - .0625rem);left:.4rem;width:.8rem;height:.125rem;background-color:currentColor}.k-heading-structure__item.level-6:after{content:"";position:absolute;bottom:calc(50% - .0625rem);left:.4rem;height:9999px;width:.125rem;background-color:currentColor}.k-facebook-preview{background:light-dark(#ffffff,#242526);border:1px solid light-dark(#dadde1,#3e4042);overflow:hidden;border-radius:var(--rounded)}.k-facebook-preview__image{width:100%;height:0;padding-bottom:52.355%;position:relative}.k-facebook-preview__image img{position:absolute;top:0;left:0;width:100%;height:100%;object-fit:cover}.k-facebook-preview__content{padding:.75rem 1rem;background:light-dark(#f0f2f5,#363638)}.k-facebook-preview__title,.k-facebook-preview__description,.k-facebook-preview__url{display:-webkit-box;-webkit-box-orient:vertical;overflow:hidden;-webkit-line-clamp:1}.k-facebook-preview__url{color:light-dark(#65676b,#b0b3b8);font-size:.75rem;text-transform:uppercase;line-height:1.1;margin-bottom:.25rem}.k-facebook-preview__title{font-weight:600;line-height:1.1765;font-size:1rem;color:light-dark(#050505,#e4e6eb);margin:.3125rem 0}.k-facebook-preview__description{line-height:1.3333;color:light-dark(#65676b,#b0b3b8);font-size:.875rem}.k-google-search-preview{padding:1rem;background:var(--input-color-back);border-radius:var(--input-rounded);overflow:hidden}.k-google-search-preview__header{display:flex;align-items:center;gap:.75rem;margin-bottom:.75rem}.k-google-search-preview__favicon{display:inline-flex;width:26px;height:26px;align-items:center;justify-content:center;border-radius:50%;border:1px solid light-dark(#ecedef,#9aa0a6);background:light-dark(#f1f3f4,#fff);margin:0}.k-google-search-preview__favicon img{display:block;width:18px;height:18px}.k-google-search-preview__site-info{display:flex;flex-direction:column;min-width:0;flex:1}.k-google-search-preview__site-title{font-size:.875rem;color:light-dark(#202124,#bdc1c6);line-height:1.2;margin-bottom:.125rem;display:block}.k-google-search-preview__url{font-size:.75rem;color:light-dark(#5f6368,#9aa0a6);line-height:1.2;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;overflow:hidden}.k-google-search-preview__title{margin:0;font-size:1.25rem;font-weight:400;color:light-dark(#1a0dab,#99c3ff);line-height:1.2;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:1;overflow:hidden}.k-google-search-preview__description{margin:.25rem 0 0;font-size:.875rem;color:light-dark(#4d5156,#bfbfbf);line-height:1.4;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;overflow:hidden}.k-slack-preview{max-width:32.5rem;position:relative;padding-left:1rem;line-height:1.46666667;font-size:.9375rem}.k-slack-preview:before{position:absolute;content:"";top:0;left:0;bottom:0;width:.25rem;border-radius:.5rem;background:light-dark(#ddd,#4a4b4d)}.k-slack-preview__site-name{display:flex;align-items:center;gap:.25rem;color:light-dark(#616061,#d1d2d3);font-size:.75rem;margin-bottom:.25rem}.k-slack-preview__favicon{width:16px;height:16px}.k-slack-preview__title{font-weight:700;display:block;color:light-dark(#1264a3,#1d9bd1);cursor:pointer;margin-bottom:.25rem}.k-slack-preview__title:hover{text-decoration:underline}.k-slack-preview__description{color:light-dark(#1d1c1d,#d1d2d3);margin:0 0 .25rem}.k-slack-preview__image-toggle{color:light-dark(#1264a3,#1d9bd1);margin-left:.25rem;font-size:.625rem;background:none;border:none;padding:0;cursor:pointer;font-family:inherit}.k-slack-preview__image-toggle:hover{opacity:.7}.k-slack-preview__image{border-radius:.5rem;max-width:22.5rem;overflow:hidden;position:relative}.k-slack-preview__image:before{border-radius:.5rem;content:"";top:0;right:0;bottom:0;left:0;z-index:2;position:absolute;box-shadow:inset 0 0 0 1px #0000001a}.k-slack-preview__image img{width:100%;height:100%;display:block}.k-seo-preview__inner{margin-top:var(--spacing-2)}.k-seo-preview__debugger{margin-top:var(--spacing-4);display:flex;font-size:var(--text-sm);color:var(--color-text-dimmed);line-height:var(--spacing-5);width:max-content;margin-left:auto}.k-seo-preview__debugger:hover{text-decoration:underline;color:var(--theme-color-text)}.k-seo-preview__debugger>.k-icon{margin-left:var(--spacing-2)}.k-seo-preview__label{display:flex;align-items:center;justify-content:flex-start;gap:var(--spacing-2)}.k-seo-preview__label>.k-icon{color:var(--theme-color-icon)}.k-seo-preview__panel-button{margin-left:auto}.k-search-console-empty{flex-direction:column;text-align:center;padding:var(--spacing-6)!important;gap:var(--spacing-3)}.k-search-console__inner{margin-top:var(--spacing-2)}.k-search-console__list{--table-color-back: light-dark(var(--color-white), var(--color-gray-850));--table-color-border: light-dark(rgba(0, 0, 0, .08), rgba(0, 0, 0, .375));background:var(--table-color-back);border-radius:var(--rounded);overflow:hidden;box-shadow:var(--shadow)}.k-search-console__row{position:relative;display:flex;align-items:center;justify-content:space-between;padding:var(--spacing-2) var(--spacing-3);font-size:var(--text-sm);border-bottom:1px solid var(--table-color-border)}.k-search-console__row:last-child{border-bottom:none}.k-search-console__row>.k-search-console__bar{position:absolute;top:0;bottom:0;left:0;right:auto;background:light-dark(var(--color-blue-200),var(--color-blue-300));opacity:light-dark(.75,.2);pointer-events:none}.k-search-console__row>.k-search-console__query,.k-search-console__row>.k-search-console__value{position:relative}.k-search-console__row>.k-search-console__query{flex:1;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding-right:var(--spacing-3)}.k-search-console__row>.k-search-console__value{font-variant-numeric:tabular-nums;color:var(--color-text-dimmed)}.k-search-console__options{margin-left:auto}.k-search-console__link{display:flex;margin-top:var(--spacing-4);margin-left:auto;width:max-content;font-size:var(--text-sm);color:var(--color-text-dimmed);line-height:var(--spacing-5)}.k-search-console__link:hover{text-decoration:underline;color:var(--theme-color-text)}.k-search-console__link>.k-icon{margin-left:var(--spacing-2)} diff --git a/site/plugins/kirby-seo/index.js b/site/plugins/kirby-seo/index.js new file mode 100644 index 0000000..a25ccb6 --- /dev/null +++ b/site/plugins/kirby-seo/index.js @@ -0,0 +1,5 @@ +(function(){"use strict";function f(o,e,t,s,a,n,u,i){var l=typeof o=="function"?o.options:o;return e&&(l.render=e,l.staticRenderFns=t,l._compiled=!0),{exports:o,options:l}}const D={extends:"k-writer-field",props:{ai:[String,Boolean]},data(){return{aiStreaming:!1,aiAbortController:null}},computed:{buttons(){if(!this.ai)return[];if(this.aiStreaming)return[{icon:"loader",text:this.$t("seo.ai.action.stop"),disabled:this.disabled||!this.aiEndpointUrl,theme:"red",click:()=>this.abortAiStream()}];const o=[{icon:this.value===""?"seo-ai":"refresh",text:this.value===""?this.$t("seo.ai.action.generate"):this.$t("seo.ai.action.regenerate"),disabled:this.disabled||!this.aiEndpointUrl,click:()=>this.startAiStream()},{icon:"cog",title:this.$t("seo.ai.action.customize"),disabled:this.disabled||!this.aiEndpointUrl,click:()=>this.openCustomizeDialog()}];return this.value!==""?[{icon:"seo-ai",text:this.$t("seo.ai.action.edit"),disabled:this.disabled||!this.aiEndpointUrl,click:()=>this.openEditDialog()},...o]:o},aiEndpointUrl(){var t,s,a;const o=(s=(t=this.$panel)==null?void 0:t.urls)==null?void 0:s.api,e=(a=this.endpoints)==null?void 0:a.field;return!o||!e?null:`${o}/${e}/ai/stream`.replace(/([^:]\/)\/+/g,"$1")}},beforeDestroy(){this.abortAiStream()},methods:{async startAiStream(o={}){var a,n,u,i;const e=this.aiEndpointUrl;if(!e||this.disabled||this.aiStreaming)return;(a=this.$refs.input)!=null&&a.focus&&this.$refs.input.focus();const t=this.getEditor();t&&t.clearContent();const s=new AbortController;this.aiAbortController=s,this.aiStreaming=!0;try{const l=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream","X-CSRF":(u=(n=this.$panel)==null?void 0:n.system)==null?void 0:u.csrf,"X-Language":(i=this.$panel)==null?void 0:i.language.code},body:JSON.stringify({instructions:o.instructions,edit:o.edit}),credentials:"same-origin",signal:s.signal});if(!l.ok)try{const d=await l.json();throw new Error((d==null?void 0:d.message)||this.$t("seo.ai.error.request"))}catch{throw new Error(this.$t("seo.ai.error.request"))}if(!l.body)throw new Error(this.$t("seo.ai.error.request"));await this.consumeStream(l.body.getReader())}catch(l){if(l&&l.name==="AbortError")return;console.error(l);const d=l&&l.message?l.message:this.$t("seo.ai.error.request");this.$panel.notification.error(d)}finally{this.aiAbortController=null,this.aiStreaming=!1}},async consumeStream(o){const e=new TextDecoder;let t="";try{for(;;){const{value:s,done:a}=await o.read();if(a)break;s&&(t+=e.decode(s,{stream:!0}),t=this.processStreamBuffer(t))}t+=e.decode(),this.processStreamBuffer(t)}finally{o&&typeof o.releaseLock=="function"&&o.releaseLock()}},processStreamBuffer(o){let e=o;for(;;){const t=e.indexOf(` + +`);if(t===-1)return e;const s=e.slice(0,t);if(e=e.slice(t+2),s.trim()==="")continue;const a=s.split(` +`).filter(n=>n.trim().startsWith("data:")).map(n=>n.trim().slice(5)).join(` +`).trim();a!==""&&this.handleAiEvent(a)}},handleAiEvent(o){let e=null;try{e=JSON.parse(o)}catch(t){console.error("Failed to parse AI chunk",t,o);return}if(e.type!=="text-start"){if(e.type==="text-delta"){this.applyAiDelta(e.text||"");return}if(e.type!=="thinking-delta"&&!(e.type==="tool-call"||e.type==="tool-result")&&e.type!=="stream-end"&&e.type==="error")throw new Error(e.payload&&e.payload.message?e.payload.message:this.$t("seo.ai.error.request"))}},applyAiDelta(o){if(!o)return;const e=this.getEditor();if(!e)return;const{state:t,view:s}=e;if(!t||!s)return;const a=t.doc.content.size,n=t.schema.text(o),u=t.tr.insert(a,n);s.dispatch(u)},getEditor(){var e,t;const o=(t=(e=this.$refs.input)==null?void 0:e.$refs)==null?void 0:t.input;return(o==null?void 0:o.editor)||null},abortAiStream(){this.aiAbortController&&(this.aiAbortController.abort(),this.aiAbortController=null),this.aiStreaming=!1},openEditDialog(){this.$panel.dialog.open({component:"k-form-dialog",props:{fields:{instructions:{label:this.$t("seo.ai.dialog.instructions.label"),type:"textarea",buttons:!1,placeholder:this.$t("seo.ai.dialog.instructions.placeholder"),required:!0}},submitButton:this.$t("seo.ai.dialog.edit.submit")},on:{submit:o=>{this.$panel.dialog.close(),this.startAiStream({edit:this.value,instructions:o.instructions})}}})},openCustomizeDialog(){this.$panel.dialog.open({component:"k-form-dialog",props:{fields:{instructions:{label:this.$t("seo.ai.dialog.custom.label"),type:"textarea",buttons:!1,placeholder:this.$t("seo.ai.dialog.custom.placeholder"),required:!0}},submitButton:this.$t("seo.ai.dialog.custom.submit")},on:{submit:o=>{this.$panel.dialog.close(),this.startAiStream({instructions:o.instructions})}}})}}};var I=function(){var e=this,t=e._self._c;return t("k-field",e._b({class:["k-writer-field",e.$attrs.class],style:e.$attrs.style,attrs:{counter:e.counterOptions,input:e.id},scopedSlots:e._u([e.disabled?null:{key:"options",fn:function(){return[t("k-button-group",{ref:"buttons",staticClass:"k-field-options",attrs:{buttons:e.buttons,layout:"collapsed",size:"xs",variant:"filled"}})]},proxy:!0}],null,!0)},"k-field",e.$props,!1),[t("k-input",e._b({ref:"input",attrs:{after:e.after,before:e.before,icon:e.icon,type:"seo-writer"},on:{input:function(s){return e.$emit("input",s)}}},"k-input",e.$props,!1))],1)},O=[],U=f(D,I,O);const F=U.exports,M={extends:"k-writer-input",methods:{createNodes(){return Vue.component("k-writer-input").options.methods.createNodes.call(this).filter(e=>e.name!=="hardBreak")}}};var B=function(){var e=this,t=e._self._c;return t("div",{directives:[{name:"direction",rawName:"v-direction"}],ref:"editor",class:["k-writer","k-writer-input",e.$attrs.class],style:e.$attrs.style,attrs:{"data-disabled":e.disabled,"data-empty":e.isEmpty,"data-placeholder":e.placeholder,spellcheck:e.spellcheck}},[e.editor&&!e.disabled?t("k-writer-toolbar",e._b({ref:"toolbar",on:{command:e.onCommand}},"k-writer-toolbar",e.toolbarOptions,!1)):e._e(),t("textarea",{ref:"output",staticClass:"input-hidden",attrs:{name:e.name,required:e.required,tabindex:"-1"},domProps:{value:e.value}})],1)},V=[],z=f(M,B,V);const H=z.exports,r=window.Vue;function y(){return window.panel}function L(){return y().api}function q(){return y().app}function R(){const o=L();return{load:({parent:t,name:s})=>o.get(`${t}/sections/${s}`)}}const m=r.computed;r.customRef,r.defineAsyncComponent,r.defineComponent,r.effectScope,r.getCurrentInstance,r.getCurrentScope,r.h,r.inject,r.isProxy,r.isReactive,r.isReadonly,r.isRef,r.isShallow,r.markRaw;const Z=r.nextTick;r.onActivated,r.onBeforeMount,r.onBeforeUnmount,r.onBeforeUpdate,r.onDeactivated,r.onErrorCaptured;const C=r.onMounted;r.onRenderTracked,r.onRenderTriggered,r.onScopeDispose,r.onServerPrefetch;const S=r.onUnmounted;r.onUpdated,r.provide,r.proxyRefs,r.reactive,r.readonly;const v=r.ref;r.shallowReactive,r.shallowReadonly,r.shallowRef,r.toRaw,r.toRef,r.toRefs,r.triggerRef,r.unref,r.useAttrs,r.useCssModule,r.useCssVars,r.useListeners,r.useSlots;const x=r.watch;r.watchEffect,r.watchPostEffect,r.watchSyncEffect;const j={__name:"utm-share-dialog",props:{pageUrl:{type:String,required:!0},visible:{type:Boolean,default:!0},size:{type:String,default:"medium"}},emits:["cancel"],setup(o,{emit:e}){const t=o,s=v({utm_source:"",utm_medium:"",utm_campaign:"",utm_content:"",utm_term:"",ref:""}),a=[{key:"utm_source",icon:"globe",name:"source"},{key:"utm_medium",icon:"dashboard",name:"medium"},{key:"utm_campaign",icon:"megaphone",name:"campaign"},{key:"utm_content",icon:"image",name:"content"},{key:"utm_term",icon:"search",name:"term"},{key:"ref",icon:"url",name:"ref"}],n=v(!1),u=v(null),i=m(()=>{const c=new URL(t.pageUrl);for(const p of a)s.value[p.key]&&c.searchParams.set(p.key,s.value[p.key]);return c.toString()}),l=async()=>{try{await navigator.clipboard.writeText(i.value),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch(c){console.error("Failed to copy:",c)}};x(i,()=>{Z(()=>{u.value&&(u.value.scrollLeft=u.value.scrollWidth)})});const d=c=>{var p;t.visible&&(c.ctrlKey||c.metaKey)&&c.key==="c"&&!((p=window.getSelection())!=null&&p.toString())&&(c.preventDefault(),l())};return C(()=>{document.addEventListener("keydown",d)}),S(()=>{document.removeEventListener("keydown",d)}),{__sfc:!0,props:t,emit:e,params:s,fields:a,copied:n,urlInput:u,generatedUrl:i,copyToClipboard:l,handleKeydown:d}}};var W=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("k-dialog",{staticClass:"k-seo-utm-share-dialog",attrs:{size:e.size,visible:e.visible,"cancel-button":!1,"submit-button":!1},on:{cancel:function(a){return s.emit("cancel")}},scopedSlots:e._u([{key:"header",fn:function(){return[t("k-button",{staticClass:"k-seo-utm-share-dialog__close",attrs:{icon:"cancel"},on:{click:function(a){return s.emit("cancel")}}})]},proxy:!0}])},[t("div",{staticClass:"k-seo-utm-share-dialog__url-wrapper"},[t("k-label",{staticClass:"k-seo-utm-share-dialog__section-label"},[e._v(e._s(e.$t("seo.utmShare.button")))]),t("div",{staticClass:"k-input k-seo-utm-share-dialog__url"},[t("span",{staticClass:"k-input-element"},[t("input",{ref:"urlInput",staticClass:"k-string-input",attrs:{id:"generated-url",type:"text",readonly:"","data-font":"monospace"},domProps:{value:s.generatedUrl},on:{focus:function(a){return a.target.select()}}})]),t("k-button",{staticClass:"k-seo-utm-share-dialog__copy",attrs:{icon:s.copied?"check":"copy",theme:s.copied?"positive":"notice",variant:"filled"},on:{click:s.copyToClipboard}})],1)],1),t("k-label",{staticClass:"k-seo-utm-share-dialog__section-label"},[e._v(e._s(e.$t("seo.utmShare.parameters")))]),t("div",{staticClass:"k-seo-utm-share-dialog__params"},e._l(s.fields,function(a){return t("div",{key:a.key,staticClass:"k-seo-utm-share-dialog__row"},[t("label",{staticClass:"k-seo-utm-share-dialog__label",attrs:{for:a.key}},[t("k-icon",{attrs:{type:a.icon}}),e._v(" "+e._s(e.$t(`seo.utmShare.${a.name}.label`))+" ")],1),t("k-input",{staticClass:"k-seo-utm-share-dialog__input"},[t("k-text-input",{attrs:{id:a.key,placeholder:e.$t(`seo.utmShare.${a.name}.placeholder`)},model:{value:s.params[a.key],callback:function(n){e.$set(s.params,a.key,n)},expression:"params[field.key]"}})],1)],1)}),0)],1)},G=[],K=f(j,W,G);const Y=K.exports,J={__name:"gsc-drawer",props:{columns:Object,rows:Array,parent:String,metric:String,sortAsc:Boolean,total:Number,page:Number,limit:Number,visible:Boolean,current:Boolean,icon:String,title:String,breadcrumb:Array,tabs:Object,tab:String,options:Array},emits:["cancel","crumb","submit","tab"],setup(o,{emit:e}){const t=o,s=Vue.computed(()=>({page:t.page,limit:t.limit,total:t.total,details:!0})),a=(i={})=>{window.panel.drawer.refresh({query:{metric:i.metric??t.metric,asc:i.asc??t.sortAsc?1:0,page:i.page??t.page}})};return{__sfc:!0,props:t,emit:e,pagination:s,reload:a,handlePaginate:i=>a({page:i.page}),handleHeader:({columnIndex:i})=>{const l=t.metric===i?!t.sortAsc:i==="position"||i==="query";a({metric:i,asc:l,page:1})}}}};var X=function(){var a;var e=this,t=e._self._c,s=e._self._setupProxy;return t("k-drawer",e._b({staticClass:"k-gsc-drawer",on:{cancel:function(n){return s.emit("cancel")},crumb:function(n){return s.emit("crumb",n)},submit:function(n){return s.emit("cancel")},tab:function(n){return s.emit("tab",n)}}},"k-drawer",e.$props,!1),[(a=s.props.rows)!=null&&a.length?t("k-table",{attrs:{columns:s.props.columns,rows:s.props.rows,index:!1,pagination:s.pagination},on:{header:s.handleHeader,paginate:s.handlePaginate},scopedSlots:e._u([{key:"header",fn:function({columnIndex:n,label:u}){return[t("span",[e._v(" "+e._s(u)+" "),s.props.metric===n?t("k-icon",{attrs:{type:s.props.sortAsc?"angle-up":"angle-down"}}):e._e()],1)]}}])}):t("k-box",{attrs:{theme:"empty"}},[t("k-text",[e._v(e._s(e.$t("seo.sections.searchConsole.noData")))])],1)],1)},Q=[],ee=f(J,X,Q);const te=ee.exports,A=o=>{const e={theme:"blue",...o};return{get button(){var t,s;return{id:e.name,icon:e.icon,label:(s=(t=window.panel)==null?void 0:t.$t)==null?void 0:s.call(t,e.label),name:e.name,inline:!0}},get schema(){return{group:"inline",inline:!0,atom:!0,selectable:!1,attrs:{variable:{default:e.variable}},leafText:t=>`{{ ${t.attrs.variable} }}`,parseDOM:[{tag:`span[data-seo-template-variable="${e.variable}"]`,getAttrs:t=>({variable:t.dataset.seoTemplateVariable??e.variable})}],toDOM:t=>["span",{"data-seo-template-variable":t.attrs.variable},`{{ ${t.attrs.variable} }}`]}},commands({type:t}){return()=>(s,a)=>{if(!a)return!1;const{from:n,to:u}=s.selection,i=t.create({variable:e.variable}),l=s.tr;l.delete(n,u),l.insert(n,i),l.insertText(" ",n+i.nodeSize);const d=s.selection.constructor,c=n+i.nodeSize+1;return l.setSelection(d.near(l.doc.resolve(c))),a(l.scrollIntoView()),!0}},view(t){var a,n;const s=document.createElement("span");return s.className="k-seo-template-variable",s.dataset.theme=e.theme,s.dataset.seoTemplateVariable=t.attrs.variable,s.setAttribute("contenteditable","false"),s.textContent=(n=(a=window.panel)==null?void 0:a.$t)==null?void 0:n.call(a,e.label),{dom:s,update(u){var i,l;return s.dataset.seoTemplateVariable=u.attrs.variable,s.textContent=(l=(i=window.panel)==null?void 0:i.$t)==null?void 0:l.call(i,e.label),!0},ignoreMutation:()=>!0}}}},T={blueprint:String,lock:[Boolean,Object],help:String,name:String,parent:String,timestamp:Number},se={__name:"heading-structure",props:T,setup(o){const e=o,t=y(),{load:s}=R(),a=v(null),n=m(()=>{var c;return(c=a.value)==null?void 0:c.some((p,k)=>{var _;return p.level>(((_=a.value[k-1])==null?void 0:_.level)??0)+1})}),u=m(()=>{var c;return((c=a.value)==null?void 0:c.filter(p=>p.level===1).length)>1}),i=m(()=>{var c;return((c=a.value)==null?void 0:c.filter(p=>p.level===1).length)===0}),l=()=>s({parent:e.parent,name:e.name}).then(c=>{a.value=c.data}),d=(c,p)=>{var k;return!!(c.level>(((k=a.value[p-1])==null?void 0:k.level)??0)+1||c.level===1&&a.value[p-1]||c.level===1&&a.value.filter(_=>_.level===1).length>1)};return C(()=>{l(),t.events.on("content.save",c=>{l()})}),S(()=>t.events.off("content.save")),{__sfc:!0,props:e,panel:t,load:s,data:a,incorrectOrder:n,multipleH1:u,noH1:i,handleLoad:l,itemInvalid:d}}};var ae=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return s.data?t("div",{staticClass:"k-section k-heading-structure"},[t("div",{staticClass:"k-field-header k-heading-structure__label k-label k-field-label"},[t("k-icon",{attrs:{type:"headline"}}),t("span",{staticClass:"k-label-text"},[e._v(e._s(s.props.label||e.$t("seo.sections.headingStructure.title")))])],1),t("k-box",{attrs:{theme:"white"}},[t("ol",{staticClass:"k-heading-structure__list"},e._l(s.data,function(a,n){return t("li",{key:n,class:`k-heading-structure__item level-${a.level} ${s.itemInvalid(a,n)?"is-invalid":""}`,style:`z-index: ${s.data.length-n}`},[t("span",{staticClass:"k-heading-structure__item__level"},[e._v(" H"+e._s(a.level)+" ")]),t("span",{staticClass:"k-heading-structure__item__text"},[e._v(e._s(a.text))])])}),0)]),s.incorrectOrder&&!s.noH1?t("k-box",{staticClass:"k-heading-structure__notice",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),t("k-text",[e._v(e._s(e.$t("seo.sections.headingStructure.errors.incorrectOrder")))])],1):e._e(),s.multipleH1?t("k-box",{staticClass:"k-heading-structure__notice",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),t("k-text",[e._v(e._s(e.$t("seo.sections.headingStructure.errors.multipleH1")))])],1):e._e(),s.noH1?t("k-box",{staticClass:"k-heading-structure__notice",attrs:{theme:"negative"}},[t("k-icon",{attrs:{type:"alert"}}),t("k-text",[e._v(e._s(e.$t("seo.sections.headingStructure.errors.missingH1")))])],1):e._e()],1):e._e()},oe=[],re=f(se,ae,oe);const ne=re.exports,ie={__name:"facebook-preview",props:{ogTitle:String,url:String,ogDescription:String,ogImage:String},setup(o){const e=o,t=m(()=>new window.URL(e.url).host);return{__sfc:!0,props:e,host:t}}};var le=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",[t("div",{staticClass:"k-facebook-preview"},[e.ogImage?t("div",{staticClass:"k-facebook-preview__image"},[t("img",{staticClass:"k-facebook-preview__img",attrs:{src:e.ogImage}})]):e._e(),t("div",{staticClass:"k-facebook-preview__content"},[t("span",{staticClass:"k-facebook-preview__url"},[e._v(e._s(s.host))]),t("span",{staticClass:"k-facebook-preview__title"},[e._v(e._s(e.ogTitle))]),t("p",{staticClass:"k-facebook-preview__description"},[e._v(e._s(e.ogDescription))])])]),t("a",{staticClass:"k-seo-preview__debugger",attrs:{href:"https://developers.facebook.com/tools/debug/","aria-label":"Facebook Sharing Debugger",target:"_blank",rel:"noopener noreferrer"}},[e._v(" "+e._s(e.$t("seo.sections.preview.openDebugger"))+" "),t("k-icon",{attrs:{type:"open"}})],1)])},ce=[],ue=f(ie,le,ce);const pe=ue.exports,de={__name:"google-preview",props:{title:String,url:String,description:String,ogSiteName:String},setup(o){const e=o,t=m(()=>new window.URL(e.url).origin),s=m(()=>new window.URL(e.url).pathname),a=m(()=>new window.URL(e.url).hostname),n=m(()=>{const u=s.value;if(!u||u==="/")return"";const i=u.split("/").filter(Boolean);return i.length===0?"":i.length===1?` › ${i[0]}`:` › … › ${i[i.length-1]}`});return{__sfc:!0,props:e,origin:t,pathname:s,domain:a,breadcrumbs:n}}};var _e=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"k-google-search-preview"},[t("div",{staticClass:"k-google-search-preview__header"},[t("img",{staticClass:"k-google-search-preview__favicon",attrs:{src:`https://www.google.com/s2/favicons?domain=${s.domain}&sz=32`,alt:`${e.ogSiteName} favicon`}}),t("div",{staticClass:"k-google-search-preview__site-info"},[t("span",{staticClass:"k-google-search-preview__site-title"},[e._v(e._s(e.ogSiteName))]),t("span",{staticClass:"k-google-search-preview__url"},[e._v(" "+e._s(s.origin)+e._s(s.breadcrumbs)+" ")])])]),t("h3",{staticClass:"k-google-search-preview__title"},[e._v(e._s(e.title))]),e.description?t("p",{staticClass:"k-google-search-preview__description"},[e._v(" "+e._s(e.description)+" ")]):e._e()])},me=[],ve=f(de,_e,me);const fe=ve.exports,he={__name:"slack-preview",props:{ogTitle:String,ogSiteName:String,ogDescription:String,ogImage:String,url:String},setup(o){const e=o,t=m(()=>new window.URL(e.url).origin),s=m(()=>new window.URL(e.url).hostname),a=v(!0);return{__sfc:!0,props:e,origin:t,domain:s,showImage:a}}};var ge=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("div",{staticClass:"k-slack-preview"},[t("div",{staticClass:"k-slack-preview__content"},[t("div",{staticClass:"k-slack-preview__site-name"},[t("img",{staticClass:"k-slack-preview__favicon",attrs:{src:`https://www.google.com/s2/favicons?domain=${s.domain}&sz=16`,alt:`${e.ogSiteName} favicon`}}),e._v(" "+e._s(e.ogSiteName||s.origin)+" ")]),t("span",{staticClass:"k-slack-preview__title"},[e._v(e._s(e.ogTitle))]),t("p",{staticClass:"k-slack-preview__description"},[e._v(" "+e._s(e.ogDescription)+" "),e.ogImage?t("button",{staticClass:"k-slack-preview__image-toggle",on:{click:function(a){s.showImage=!s.showImage}}},[e._v(" "+e._s(s.showImage?"▼":"▶")+" ")]):e._e()])]),e.ogImage&&s.showImage?t("div",{staticClass:"k-slack-preview__image"},[t("img",{attrs:{src:e.ogImage}})]):e._e()])},ke=[],be=f(he,ge,ke);const we=be.exports,ye={__name:"seo-preview",props:T,setup(o){const e=o,t=y(),s=q(),{load:a}=R(),n=v(null),u=v([]),i=m(()=>e.parent==="site"),l=m(()=>e.label||t.t("seo.sections.preview.title")),d=m(()=>{var E;const _=(E=n.value)==null?void 0:E.pageTitle;return i.value&&_?t.t("seo.sections.preview.titleWithPage",{title:_}):l.value}),c=v(window.localStorage.getItem("kSEOPreviewType")??"google");x(c,_=>{window.localStorage.setItem("kSEOPreviewType",_)});const p=()=>{a({parent:e.parent,name:e.name}).then(_=>{n.value=_.meta,u.value=_.options,!window.localStorage.getItem("kSEOPreviewType")&&_.options.length>0&&(c.value=_.options[0].value)})},k=()=>{var _;(_=n.value)!=null&&_.panelUrl&&s.$go(n.value.panelUrl)};return C(()=>{p(),t.events.on("content.save",_=>{p()})}),S(()=>t.events.off("content.save")),{__sfc:!0,props:e,panel:t,app:s,load:a,meta:n,options:u,isSiteParent:i,baseLabel:l,headerLabel:d,type:c,handleLoad:p,openPanelTarget:k,FacebookPreview:pe,GooglePreview:fe,SlackPreview:we}}};var Ce=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return s.meta?t("k-section",{staticClass:"k-seo-preview"},[t("div",{staticClass:"k-field-header k-seo-preview__label k-label k-field-label"},[t("k-icon",{attrs:{type:"preview"}}),t("span",{staticClass:"k-label-text"},[e._v(" "+e._s(s.headerLabel)+" ")]),s.isSiteParent&&s.meta.panelUrl?t("k-button",{staticClass:"k-seo-preview__panel-button",attrs:{variant:"filled",size:"xs",icon:"edit"},on:{click:s.openPanelTarget}},[e._v(" "+e._s(e.$t("seo.sections.preview.viewPage"))+" ")]):e._e()],1),t("k-select-field",{attrs:{type:"select",name:"seo-preview-type",before:e.$t("seo.sections.preview.showFor"),options:s.options,required:!0,empty:!1},model:{value:s.type,callback:function(a){s.type=a},expression:"type"}}),t("div",{staticClass:"k-seo-preview__inner"},[s.type==="google"?t(s.GooglePreview,e._b({},"google-preview",s.meta,!1)):e._e(),s.type==="facebook"?t(s.FacebookPreview,e._b({},"facebook-preview",s.meta,!1)):e._e(),s.type==="slack"?t(s.SlackPreview,e._b({},"slack-preview",s.meta,!1)):e._e()],1)],1):e._e()},$e=[],Se=f(ye,Ce,$e);const xe=Se.exports,Te={__name:"search-console",props:T,setup(o){const e=o,t={NO_CREDENTIALS:"seo.sections.searchConsole.noCredentials",NOT_CONNECTED:"seo.sections.searchConsole.notConnected",SELECT_PROPERTY:"seo.sections.searchConsole.selectProperty"},s=y(),a=L(),n=v(null),u=v([]),i=v("clicks"),l=v(null),d=v("clicks"),c=[{value:"clicks",text:s.t("seo.sections.searchConsole.clicks")},{value:"impressions",text:s.t("seo.sections.searchConsole.impressions")},{value:"ctr",text:s.t("seo.sections.searchConsole.ctr")},{value:"position",text:s.t("seo.sections.searchConsole.position")}],p=async()=>{const h=await a.get(`${e.parent}/sections/${e.name}`,{metric:d.value,limit:10});n.value=h.status,u.value=h.data??[],i.value=d.value};return x(d,()=>p()),C(()=>{p(),s.events.on("gsc.propertySelected",()=>{p()})}),{__sfc:!0,MESSAGES:t,props:e,panel:s,api:a,status:n,data:u,displayMetric:i,dropdown:l,metric:d,metricOptions:c,handleLoad:p,getBarWidth:h=>{if(!u.value.length)return 0;const b=i.value,w=u.value.map(Ae=>Ae[b]),g=Math.min(...w),$=Math.max(...w),N=h[b];if($===g)return 100;let P;return b==="position"?P=($-N)/($-g):P=(N-g)/($-g),10+P*90},formatValue:h=>{const b=i.value,w=h[b],g=s.translation.code;return b==="ctr"?new Intl.NumberFormat(g,{style:"percent",minimumFractionDigits:1,maximumFractionDigits:1}).format(w):b==="position"?new Intl.NumberFormat(g,{minimumFractionDigits:1,maximumFractionDigits:1}).format(w):new Intl.NumberFormat(g).format(w)},handleConnect:()=>{const h=encodeURIComponent(window.location.href);window.location.href=`/__seo/gsc/auth?return=${h}`},handleSelectProperty:()=>s.dialog.open("seo/gsc/select-property")}}};var Ee=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return s.status?t("k-section",{staticClass:"k-search-console-section"},[t("div",{staticClass:"k-field-header k-seo-preview__label k-label k-field-label"},[t("k-icon",{attrs:{type:"google"}}),t("span",{staticClass:"k-label-text"},[e._v(" "+e._s(e.label||"Google Search Console")+" ")]),s.status==="CONNECTED"?t("k-button-group",{staticClass:"k-search-console__options",attrs:{layout:"collapsed"}},[t("k-button",{attrs:{size:"xs",variant:"filled",icon:"table"},on:{click:function(a){return s.panel.drawer.open(`seo/gsc/data/${s.props.parent}`,{query:{metric:s.metric}})}}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.showMore"))+" ")]),t("k-button",{attrs:{icon:"dots",size:"xs",variant:"filled"},on:{click:function(a){return s.dropdown.toggle()}}}),t("k-dropdown-content",{ref:"dropdown",attrs:{"align-x":"end"}},[t("k-dropdown-item",{attrs:{icon:"list-bullet"},on:{click:s.handleSelectProperty}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.selectPropertyButton"))+" ")]),t("k-dropdown-item",{attrs:{icon:"refresh"},on:{click:s.handleConnect}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.reconnect"))+" ")])],1)],1):e._e()],1),s.status!=="CONNECTED"?t("k-box",{staticClass:"k-search-console-empty",attrs:{align:"center",theme:"empty"}},[t("k-text",[e._v(e._s(e.$t(s.MESSAGES[s.status])))]),t("k-button-group",[s.status==="NO_CREDENTIALS"?t("k-button",{attrs:{size:"sm",variant:"filled",icon:"page",link:"https://plugins.andkindness.com/seo/docs/get-started/feature-overview",target:"_blank"}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.docs"))+" ")]):e._e(),s.status==="NOT_CONNECTED"?t("k-button",{attrs:{size:"sm",variant:"filled",icon:"google"},on:{click:s.handleConnect}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.connect"))+" ")]):e._e(),s.status==="SELECT_PROPERTY"?t("k-button",{attrs:{size:"sm",variant:"filled",theme:"positive",icon:"list-bullet"},on:{click:s.handleSelectProperty}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.selectPropertyButton"))+" ")]):e._e(),s.status==="SELECT_PROPERTY"?t("k-button",{attrs:{size:"sm",variant:"filled",icon:"refresh"},on:{click:s.handleConnect}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.reconnect"))+" ")]):e._e()],1)],1):[t("k-select-field",{attrs:{type:"select",name:"gsc-metric",before:e.$t("seo.sections.searchConsole.sortBy"),options:s.metricOptions,required:!0,empty:!1},model:{value:s.metric,callback:function(a){s.metric=a},expression:"metric"}}),t("div",{staticClass:"k-search-console__inner"},[s.data.length?t("div",{staticClass:"k-search-console__list"},e._l(s.data,function(a){return t("div",{key:a.keys[0],staticClass:"k-search-console__row"},[t("div",{staticClass:"k-search-console__bar",style:{width:s.getBarWidth(a)+"%"}}),t("span",{staticClass:"k-search-console__query"},[e._v(e._s(a.keys[0]))]),t("span",{staticClass:"k-search-console__value"},[e._v(e._s(s.formatValue(a)))])])}),0):t("k-box",{staticClass:"k-search-console-empty",attrs:{theme:"empty"}},[t("k-text",[e._v(e._s(e.$t("seo.sections.searchConsole.noData")))])],1)],1),t("a",{staticClass:"k-search-console__link",attrs:{href:"https://search.google.com/search-console",target:"_blank",rel:"noopener noreferrer"}},[e._v(" "+e._s(e.$t("seo.sections.searchConsole.openInGsc"))+" "),t("k-icon",{attrs:{type:"open"}})],1)]],2):e._e()},Pe=[],Le=f(Te,Ee,Pe);const Re=Le.exports;panel.plugin("tobimori/seo",{icons:{"seo-ai":'',robots:'',"robots-off":''},sections:{"heading-structure":ne,"seo-preview":xe,"seo-search-console":Re},fields:{"seo-writer":F},components:{"k-seo-writer-input":H,"k-seo-utm-share-dialog":Y,"k-gsc-drawer":te},writerNodes:{seoTemplateTitle:A({name:"seoTemplateTitle",icon:"page",variable:"title",label:"seo.writerNodes.template.title",theme:"blue"}),seoTemplateSiteTitle:A({name:"seoTemplateSiteTitle",icon:"globe",variable:"site.title",label:"seo.writerNodes.template.siteTitle",theme:"purple"})}})})(); diff --git a/site/plugins/kirby-seo/index.php b/site/plugins/kirby-seo/index.php new file mode 100644 index 0000000..a88509f --- /dev/null +++ b/site/plugins/kirby-seo/index.php @@ -0,0 +1,95 @@ +=') === true +) { + throw new Exception('Kirby SEO requires Kirby 5'); +} + +App::plugin( + 'tobimori/seo', + // TODO: license + extends: [ + 'options' => require __DIR__ . '/config/options.php', + 'sections' => require __DIR__ . '/config/sections.php', + 'areas' => require __DIR__ . '/config/areas.php', + 'siteMethods' => require __DIR__ . '/config/site-methods.php', + 'pageMethods' => require __DIR__ . '/config/page-methods.php', + 'hooks' => require __DIR__ . '/config/hooks.php', + 'routes' => require __DIR__ . '/config/routes.php', + 'fields' => require __DIR__ . '/config/fields.php', + 'permissions' => [ + 'ai' => true, + ], + 'snippets' => [ + 'seo/prompts/introduction' => __DIR__ . '/snippets/prompts/introduction.php', + 'seo/prompts/content' => __DIR__ . '/snippets/prompts/content.php', + 'seo/prompts/meta' => __DIR__ . '/snippets/prompts/meta.php', + 'seo/prompts/site-meta' => __DIR__ . '/snippets/prompts/site-meta.php', + 'seo/prompts/tasks/title' => __DIR__ . '/snippets/prompts/tasks/title.php', + 'seo/prompts/tasks/description' => __DIR__ . '/snippets/prompts/tasks/description.php', + 'seo/prompts/tasks/og-description' => __DIR__ . '/snippets/prompts/tasks/og-description.php', + 'seo/prompts/tasks/site-description' => __DIR__ . '/snippets/prompts/tasks/site-description.php', + 'seo/prompts/tasks/og-site-description' => __DIR__ . '/snippets/prompts/tasks/og-site-description.php', + 'seo/schemas' => __DIR__ . '/snippets/schemas.php', + 'seo/head' => __DIR__ . '/snippets/head.php', + 'seo/robots.txt' => __DIR__ . '/snippets/robots.txt.php', + ], + 'templates' => [ + 'sitemap' => __DIR__ . '/templates/sitemap.php', + 'sitemap.xml' => __DIR__ . '/templates/sitemap.xml.php', + 'sitemap.xsl' => __DIR__ . '/templates/sitemap.xsl.php', + ], + 'blueprints' => [ + 'seo' => require __DIR__ . '/blueprints/seo.php', + 'seo/site' => require __DIR__ . '/blueprints/seo.php', + 'seo/page' => require __DIR__ . '/blueprints/seo.php', + 'seo/fields/og-image' => require __DIR__ . '/blueprints/fields/og-image.php', + 'seo/fields/og-group' => __DIR__ . '/blueprints/fields/og-group.yml', + 'seo/fields/meta-group' => __DIR__ . '/blueprints/fields/meta-group.yml', + 'seo/fields/title-template' => __DIR__ . '/blueprints/fields/title-template.yml', + 'seo/fields/robots' => require __DIR__ . '/blueprints/fields/robots.php', + 'seo/fields/site-robots' => require __DIR__ . '/blueprints/fields/site-robots.php', + 'seo/fields/social-media' => require __DIR__ . '/blueprints/fields/social-media.php', + ], + // get all files from /translations and register them as language files + 'translations' => A::keyBy( + A::map( + Dir::files(__DIR__ . '/translations'), + function ($file) { + $translations = []; + foreach (Json::read(__DIR__ . '/translations/' . $file) as $key => $value) { + $translations["seo.{$key}"] = $value; + } + + return A::merge( + ['lang' => F::name($file)], + $translations + ); + } + ), + 'lang' + ), + ] +); + +if (!function_exists('schema')) { + function schema($type) + { + if (!class_exists('Spatie\SchemaOrg\Schema')) { + return null; + } + + return Schema::{$type}(); + } +} diff --git a/site/plugins/kirby-seo/snippets/head.php b/site/plugins/kirby-seo/snippets/head.php new file mode 100644 index 0000000..1c74b4c --- /dev/null +++ b/site/plugins/kirby-seo/snippets/head.php @@ -0,0 +1,27 @@ +metadata()->snippetData(); + +// if we're using slots, the user wants to output priority tags such as +// before their stylesheet, script, etc. tags +if (isset($slot)) { + foreach (array_filter($tags, fn ($tag) => $tag['priority']) as $tag) { + echo Html::tag($tag['tag'], $tag['content'] ?? null, $tag['attributes'] ?? []) . PHP_EOL; + } + + echo $slot; + + $tags = array_filter($tags, fn ($tag) => !$tag['priority']); +} + +// then output other tags as normal +// this is unfiltered if slots is not set. +foreach ($tags as $tag) { + echo Html::tag($tag['tag'], $tag['content'] ?? null, $tag['attributes'] ?? []) . PHP_EOL; +} diff --git a/site/plugins/kirby-seo/snippets/prompts/content.php b/site/plugins/kirby-seo/snippets/prompts/content.php new file mode 100644 index 0000000..d7d4e01 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/content.php @@ -0,0 +1,114 @@ +<?php + +use Kirby\Toolkit\Str; + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site */ + +$contentHtml = $page->render(); + +if ($contentHtml !== '' && class_exists('DOMDocument')) { + $dom = new \DOMDocument('1.0', 'UTF-8'); + $previousLibxmlState = libxml_use_internal_errors(true); + + $encoded = mb_encode_numericentity($contentHtml, [0x80, 0x10FFFF, 0, 0x1FFFFF], 'UTF-8'); + + $loaded = $dom->loadHTML('<?xml encoding="UTF-8"?>' . $encoded, LIBXML_NOERROR | LIBXML_NOWARNING | LIBXML_NONET); + + libxml_clear_errors(); + libxml_use_internal_errors($previousLibxmlState); + + if ($loaded !== false) { + foreach ( + [ + 'script', + 'style', + 'noscript', + 'template', + 'svg', + 'canvas', + 'iframe', + 'video', + 'audio', + 'object', + 'embed', + 'source', + 'track', + 'nav', + 'footer', + 'aside', + 'form', + 'button', + 'input', + 'select', + 'textarea', + 'label', + 'menu', + 'header', + ] as $tag + ) { + $nodes = $dom->getElementsByTagName($tag); + for ($i = $nodes->length - 1; $i >= 0; $i--) { + $node = $nodes->item($i); + if ($node !== null && $node->parentNode !== null) { + $node->parentNode->removeChild($node); + } + } + } + + $xpath = new \DOMXPath($dom); + foreach ( + [ + 'navigation', + 'banner', + 'contentinfo', + 'complementary', + 'search', + 'menu', + 'menubar', + 'toolbar', + ] as $role + ) { + $nodes = $xpath->query("//*[@role='{$role}']"); + if ($nodes === false) { + continue; + } + + foreach ($nodes as $node) { + if ($node->parentNode !== null) { + $node->parentNode->removeChild($node); + } + } + } + + $body = $dom->getElementsByTagName('body')->item(0) ?? $dom->documentElement; + if ($body instanceof \DOMNode) { + $innerHtml = ''; + foreach ($body->childNodes as $child) { + $innerHtml .= $dom->saveHTML($child); + } + + if ($innerHtml !== '') { + $contentHtml = $innerHtml; + } + } + } +} + +$blockClosingPattern = 'p|div|section|article|main|aside|header|footer|li|ul|ol|dl|blockquote|pre|figure|figcaption|h[1-6]|table|thead|tbody|tfoot|tr|td|th|dd|dt'; +$contentHtml = preg_replace('~<(?:br|hr)\b[^>]*?>~i', "\n", $contentHtml); +$contentHtml = preg_replace('~</(?:' . $blockClosingPattern . ')>~i', "\n", $contentHtml); + +$text = Str::unhtml($contentHtml); +$text = Str::replace($text, "\r", "\n"); +$text = preg_replace("/[ \t\x{00A0}\x{202F}\x{2007}\x{2060}]+/u", ' ', $text); +$text = preg_replace("/ *\n+ */", "\n", $text); +$text = preg_replace("/\n{3,}/", "\n\n", $text); + +$content = trim($text); + +?> + +<content> + <?= htmlspecialchars($content, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8') ?> +</content> diff --git a/site/plugins/kirby-seo/snippets/prompts/introduction.php b/site/plugins/kirby-seo/snippets/prompts/introduction.php new file mode 100644 index 0000000..5d096a4 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/introduction.php @@ -0,0 +1,46 @@ +<?php + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var string|null $edit */ ?> + +<role> + You are a professional SEO copywriter for <?= $site->title() ?>. Create high-quality content. Mimic the site's tone and style. You'll be rewarded based on the conversion rate. +</role> + +<rules> + - You MUST only output the answer without additional prose or introduction. + - You MUST mimic the site's tone and style. DO NOT shift register (informal stays informal). + - The output language MUST be <language><?= $site->lang() ?></language>. Translate the content into <?= $site->lang() ?>. + - ALWAYS and ONLY provide exactly one answer. DO NOT suggest multiple answers. + - NEVER output any formatting. No new lines, no HTML tags, no quotes, no markdown. + - NEVER output or introduce information that is not provided in the content. + - NEVER output duplicate content in the same answer. +</rules> + +<?php if (isset($edit) && $edit !== null && $edit !== '') : ?> +<primary-editing-task> + YOU ARE EDITING EXISTING CONTENT - NOT CREATING NEW CONTENT. + + Current text that needs editing: + <current-value><?= $edit ?></current-value> + + CRITICAL EDITING RULES: + - Start from the text above and modify ONLY what is requested + - Preserve as much of the original as possible + - Keep the same style, tone, and structure + - Change ONLY the specific parts mentioned in the instructions below +</primary-editing-task> +<?php endif ?> + +<?php if (isset($instructions) && $instructions !== null && $instructions !== '') : ?> +<user-instructions> + <?php if (isset($edit) && $edit !== null && $edit !== '') : ?> + Apply ONLY these changes to the text above: + <?php else : ?> + The user has provided these specific instructions: + <?php endif ?> + <?= $instructions ?> +</user-instructions> +<?php endif ?> \ No newline at end of file diff --git a/site/plugins/kirby-seo/snippets/prompts/meta.php b/site/plugins/kirby-seo/snippets/prompts/meta.php new file mode 100644 index 0000000..110dc14 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/meta.php @@ -0,0 +1,28 @@ +<?php + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $currentField */ + +$meta = $page->metadata(); +$currentField = $currentField ?? null; + +$metaFields = [ + 'metaTitle' => 'Meta Title', + 'metaDescription' => 'Meta Description', + 'ogTitle' => 'Open Graph Title', + 'ogDescription' => 'Open Graph Description' +]; +?> + +<existing-metadata> +<?php foreach ($metaFields as $key => $label) : ?> +<?php + $value = $meta->get($key); + if ($currentField === $key || !$value || $value === '') { + continue; + } + ?> + <<?= $key ?>><?= $value ?></<?= $key ?>> +<?php endforeach ?> +</existing-metadata> diff --git a/site/plugins/kirby-seo/snippets/prompts/site-meta.php b/site/plugins/kirby-seo/snippets/prompts/site-meta.php new file mode 100644 index 0000000..543aa68 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/site-meta.php @@ -0,0 +1,25 @@ +<?php + +/** @var \Kirby\Cms\Site $site + ** @var string|null $currentField */ + +$currentField = $currentField ?? null; + +$metaFields = [ + 'metaDescription' => 'Site Meta Description', + 'ogDescription' => 'Site Open Graph Description', + 'ogSiteName' => 'Site Name' +]; +?> + +<existing-site-metadata> +<?php foreach ($metaFields as $key => $label) : ?> +<?php + $value = $site->$key()->value(); + if ($currentField === $key || !$value || $value === '') { + continue; + } + ?> + <<?= $key ?>><?= $value ?></<?= $key ?>> +<?php endforeach ?> +</existing-site-metadata> diff --git a/site/plugins/kirby-seo/snippets/prompts/tasks/description.php b/site/plugins/kirby-seo/snippets/prompts/tasks/description.php new file mode 100644 index 0000000..d4d5ad5 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/tasks/description.php @@ -0,0 +1,24 @@ +<?php + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var string|null $edit */ + +$meta = $page->metadata(); + +snippet('seo/prompts/introduction', [ + 'instructions' => $instructions ?? null, + 'edit' => $edit ?? null +]); ?> + +<task> + Create a useful meta description for this page called <page-title><?= $page->title()->value() ?></page-title>. <?php if ($page->isHomePage()) : ?>This page is the homepage of the website.<?php endif ?> + + The entire meta description SHOULD be between 120 and 158 characters long. + + You'll receive the content of the page as well as any meta tags that are already set below. +</task> + +<?php snippet('seo/prompts/meta', ['currentField' => 'metaDescription']); +snippet('seo/prompts/content'); diff --git a/site/plugins/kirby-seo/snippets/prompts/tasks/og-description.php b/site/plugins/kirby-seo/snippets/prompts/tasks/og-description.php new file mode 100644 index 0000000..4c9d963 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/tasks/og-description.php @@ -0,0 +1,25 @@ +<?php + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var string|null $edit */ + +$meta = $page->metadata(); + +snippet('seo/prompts/introduction', [ + 'instructions' => $instructions ?? null, + 'edit' => $edit ?? null +]); ?> + +<task> + Create a useful open graph description for this page called <page-title><?= $page->title()->value() ?></page-title>. <?php if ($page->isHomePage()) : ?>This page is the homepage of the website.<?php endif ?> + This description will be shown on social media platforms like Facebook, WhatsApp and LinkedIn. + + The entire meta description SHOULD be between 120 and 158 characters long. + + You'll receive the content of the page as well as any meta tags that are already set below. +</task> + +<?php snippet('seo/prompts/meta', ['currentField' => 'ogDescription']); +snippet('seo/prompts/content'); diff --git a/site/plugins/kirby-seo/snippets/prompts/tasks/og-site-description.php b/site/plugins/kirby-seo/snippets/prompts/tasks/og-site-description.php new file mode 100644 index 0000000..870c091 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/tasks/og-site-description.php @@ -0,0 +1,25 @@ +<?php + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var string|null $edit */ + +snippet('seo/prompts/introduction', [ + 'instructions' => $instructions ?? null, + 'edit' => $edit ?? null +]); ?> + +<task> + Create a useful GLOBAL open graph description for this site <site-title><?= $site->title()->value() ?>.</site-title> + This description will be shown on social media platforms like Facebook, WhatsApp and LinkedIn. + This description is meant as FALLBACK for when the page does not have a meta description itself. + This description should be unique and relevant to the site's content. + + The entire meta description SHOULD be between 120 and 158 characters long. + + You'll receive the content of the home page as well as any meta tags that are already set below. +</task> + +<?php snippet('seo/prompts/site-meta', ['currentField' => 'ogDescription']); +snippet('seo/prompts/content'); ?> \ No newline at end of file diff --git a/site/plugins/kirby-seo/snippets/prompts/tasks/site-description.php b/site/plugins/kirby-seo/snippets/prompts/tasks/site-description.php new file mode 100644 index 0000000..59f4770 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/tasks/site-description.php @@ -0,0 +1,24 @@ +<?php + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var string|null $edit */ + +snippet('seo/prompts/introduction', [ + 'instructions' => $instructions ?? null, + 'edit' => $edit ?? null +]); ?> + +<task> + Create a useful GLOBAL meta description for this site <site-title><?= $site->title()->value() ?>.</site-title> + This description is meant as FALLBACK for when the page does not have a meta description itself. + This description should be unique and relevant to the site's content. + + The entire meta description SHOULD be between 120 and 158 characters long. + + You'll receive the content of the home page as well as any meta tags that are already set below. +</task> + +<?php snippet('seo/prompts/site-meta', ['currentField' => 'metaDescription']); +snippet('seo/prompts/content'); ?> \ No newline at end of file diff --git a/site/plugins/kirby-seo/snippets/prompts/tasks/title.php b/site/plugins/kirby-seo/snippets/prompts/tasks/title.php new file mode 100644 index 0000000..31ff11b --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/tasks/title.php @@ -0,0 +1,39 @@ +<?php + +use Kirby\Toolkit\Str; + +/** @var \Kirby\Cms\Page $page + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var string|null $edit */ + +$meta = $page->metadata(); + +snippet('seo/prompts/introduction', [ + 'instructions' => $instructions ?? null, + 'edit' => $edit ?? null +]); ?> + +<task> + Create a useful meta title for this page called <page-title><?= $page->title()->value() ?></page-title>. <?php if ($page->isHomePage()) : ?>This page is the homepage of the website. AVOID an overly generic title such as 'Home'.<?php endif ?> + + <?php if ($page->useTitleTemplate()->isEmpty() ? true : $page->useTitleTemplate()->toBool()): + $template = $meta->get('metaTemplate'); + $templatePreview = $page->toString($template, ['title' => '{{ title }}']); + $templateBaseLength = Str::length($page->toString($template, ['title' => ''])); + ?> + The final page title will be rendered as: + + <template><?= $templatePreview ?></template> + + Where {{ title }} is your page title. The entire title SHOULD be between <?= max(0, 50 - $templateBaseLength) ?>-<?= max(max(0, 50 - $templateBaseLength), 60 - $templateBaseLength) ?> characters long. + DO NOT output the Title Template. ONLY output what should be placed inside {{ title }}. DO NOT repeat ANYTHING that exists in the template. You MUST NOT repeat the name of the site. + <?php else: ?> + Your response will be set as title without any changes. The entire title SHOULD be between 50-60 characters long. + <?php endif; ?> + + If useful for the customers niche, include a keyword for the location. AVOID for global companies or niche subpages. +</task> + +<?php snippet('seo/prompts/meta', ['currentField' => 'metaTitle']); +snippet('seo/prompts/content'); diff --git a/site/plugins/kirby-seo/snippets/robots.txt.php b/site/plugins/kirby-seo/snippets/robots.txt.php new file mode 100644 index 0000000..0fca72f --- /dev/null +++ b/site/plugins/kirby-seo/snippets/robots.txt.php @@ -0,0 +1,52 @@ +<?php + +use Kirby\Toolkit\A; +use tobimori\Seo\Seo; + +if ($content = Seo::option('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 = Seo::option('robots.index'); + + if ($index) { + echo 'Allow: /'; + echo "\nDisallow: /panel"; + } else { + echo 'Disallow: /'; + } +} + +if (($sitemap = Seo::option('robots.sitemap')) || ($sitemapModule = Seo::option('sitemap.active'))) { + + // Use default sitemap if none is set + if (!$sitemap && $sitemapModule) { + $sitemap = site()->canonicalFor('/sitemap.xml', true); + } + + // Check again, so falsy values can't be used + if ($sitemap) { + echo "\n\nSitemap: {$sitemap}"; + } +} diff --git a/site/plugins/kirby-seo/snippets/schemas.php b/site/plugins/kirby-seo/snippets/schemas.php new file mode 100644 index 0000000..1d37c77 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/schemas.php @@ -0,0 +1,12 @@ +<?php + +if (!class_exists('Spatie\SchemaOrg\Schema')) { + return; +} + +$siteSchema ??= true; +$pageSchema ??= true; + +foreach (array_merge($siteSchema ? $site->schemas() : [], $pageSchema ? $page->schemas() : []) as $schema) { + echo $schema; +} diff --git a/site/plugins/kirby-seo/templates/sitemap.php b/site/plugins/kirby-seo/templates/sitemap.php new file mode 100644 index 0000000..618162b --- /dev/null +++ b/site/plugins/kirby-seo/templates/sitemap.php @@ -0,0 +1,3 @@ +<?php + +go($page->url() . '.xml'); diff --git a/site/plugins/kirby-seo/templates/sitemap.xml.php b/site/plugins/kirby-seo/templates/sitemap.xml.php new file mode 100644 index 0000000..f57b648 --- /dev/null +++ b/site/plugins/kirby-seo/templates/sitemap.xml.php @@ -0,0 +1,5 @@ +<?php + +use tobimori\Seo\Sitemap\SitemapIndex; + +echo SitemapIndex::instance()->render($page); diff --git a/site/plugins/kirby-seo/templates/sitemap.xsl.php b/site/plugins/kirby-seo/templates/sitemap.xsl.php new file mode 100644 index 0000000..5cf4eb4 --- /dev/null +++ b/site/plugins/kirby-seo/templates/sitemap.xsl.php @@ -0,0 +1,196 @@ +<?= '<?xml version="1.0" encoding="UTF-8"?>' ?> +<xsl:stylesheet version="2.0" xmlns:html="http://www.w3.org/TR/REC-html40" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" xmlns:sitemap="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> + <xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" /> + <xsl:template match="/"> + <html> + + <head> + <title><?= $page->metadata()->title()->escape() ?> + + + + +
+

title() ?>

+

+ + + + + + + + + + + + + + + + + +
+ + + + + + +
+
+ + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + +
+
+ + +
+ +
+
+ +

+ Kirby SEO + + v + + + v + + Tobias Möritz +

+
+ + + + + \ No newline at end of file diff --git a/site/plugins/kirby-seo/translations/cs.json b/site/plugins/kirby-seo/translations/cs.json new file mode 100644 index 0000000..6f43d23 --- /dev/null +++ b/site/plugins/kirby-seo/translations/cs.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Struktura nadpisů", + "sections.headingStructure.errors.incorrectOrder": "Struktura nadpisů má nesprávné pořadí a je tedy chybná.", + "sections.headingStructure.errors.missingH1": "Struktura nadpisů neobsahuje H1 a je tedy chybná.", + "sections.headingStructure.errors.multipleH1": "Struktura nadpisů obsahuje více než jeden H1 a je tedy chybná.", + "sections.preview.title": "Náhled", + "sections.preview.titleWithPage": "Náhled (zobrazuje „{title}\")", + "sections.preview.viewPage": "Zobrazit stránku", + "sections.preview.showFor": "Ukaž mi", + "sections.preview.openDebugger": "Otevřít Sharing Debugger", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexace povolena", + "fields.robots.indicator.any": "Částečný zákaz indexace", + "fields.robots.indicator.noindex": "Indexace zakázána", + "fields.robots.label": "Vyhledávače a crawlery", + "fields.robots.index.label": "Indexace", + "fields.robots.index.help": "Zda mohou vyhledávače tuto stránku indexovat.", + "fields.robots.follow.label": "Sledovat odkazy", + "fields.robots.follow.help": "Zda mohou vyhledávače sledovat odkazy na této stránce.", + "fields.robots.archive.label": "Archivace", + "fields.robots.archive.help": "Zda mohou vyhledávače tuto stránku archivovat.", + "fields.robots.imageindex.label": "Indexace obrázků", + "fields.robots.imageindex.help": "Zda mohou vyhledávače indexovat obrázky na této stránce.", + "fields.robots.snippet.label": "Tvorba snippetů", + "fields.robots.snippet.help": "Zda mohou vyhledávače vytvářet snippety z této stránky.", + "tabs.seo": "Metadata a SEO", + "site.meta.headline": "Globální nastavení SEO", + "site.meta.headline.help": "Toto nastavení bude použito pro všechny stránky, které nemají vlastní metadata.\nMůžete jej přepsat pro každou stránku.", + "fields.metaTitleTemplate.label": "Šablona titulku stránky", + "fields.metaTitleTemplate.help": "Šablona pro použití u všech názvů stránek.", + "fields.metaDescription.label": "Popisek stránky (description)", + "fields.metaDescription.help": "Doporučená délka je maximálně 150 znaků. Používá se, pokud není zadán popisek stránky.", + "site.og.headline": "Globální nastavení Open Graph", + "site.og.headline.help": "Nastavte, jak se vaše webové stránky zobrazují při sdílení na sociálních sítích, jako je Facebook nebo Twitter.", + "fields.ogTitleTemplate.label": "Šablona Open Graph titulku", + "fields.ogDescription.label": "Open Graph popisek (description)", + "fields.ogSiteName.label": "Open Graph název webu (site name)", + "fields.ogImage.label": "Open Graph obrázek", + "fields.ogImage.help": "Doporučená velikost 1200x630 pixelů.", + "fields.ogImage.empty": "Nebyl vybrán žádný obrázek", + "fields.cropOgImage.label": "Oříznout OG obrázek na doporučenou velikost?", + "fields.cropOgImage.help": "Doporučená velikost je 1200x630px. Při aktivaci budou obrázky automaticky oříznuty na tuto velikost pro optimální zobrazení na sociálních sítích.", + "fields.socialMediaAccounts.label": "Účty na sociálních sítích", + "fields.socialMediaAccounts.help": "Adresy URL nebo @uzivatelska-jmena vašich účtů na sociálních sítích. Slouží k umístění odkazů na vaše účty do metadat.", + "page.meta.headline": "Nastavení SEO", + "page.og.headline": "Nastavení Open Graph", + "fields.titleOverwrite.label": "Titulek stránky (přepsat)", + "fields.inheritSettings.label": "Zdědit nastavení", + "fields.inheritSettings.help": "Vyberte, která nastavení by měla být zděděna podstránkami.\nTo může být užitečné například v případě, že všechny příspěvky blogu by měly mít vlastní šablonu titulku, která se liší od výchozího nastavení webu. Všechna nastavení lze stále na hlavní stránce přepsat.", + "fields.useTitleTemplate.label": "Použít šablonu titulku?", + "fields.useTitleTemplate.no": "Ne - pouze název stránky", + "fields.useTitleTemplate.yes": "Ano - použít šablonu", + "fields.useTitleTemplate.help": "Určuje, zda se má použít šablona titulku. Nebude zděděno.", + "writerNodes.template.title": "Titulek stránky", + "writerNodes.template.siteTitle": "Titulek webu", + "common.default": "Výchozí:", + "common.yes": "Ano", + "common.no": "Ne", + "sitemap.title": "Sitemap", + "sitemap.index": "Sitemap Index", + "sitemap.description": "Toto je mapa stránek vašeho webu, která informuje vyhledávače o stránkách, které lze indexovat.", + "sitemap.by": "od", + "sitemap.changefreq": "Frekvence změn", + "sitemap.lastUpdated": "Poslední aktualizace", + "sitemap.priority": "Priorita", + "sitemap.url": "URL", + "sitemap.noEntries": "Žádné záznamy", + "utmShare.button": "Sdílet", + "utmShare.parameters": "Parametry", + "utmShare.source.label": "Zdroj", + "utmShare.source.placeholder": "např. google, newsletter", + "utmShare.medium.label": "Médium", + "utmShare.medium.placeholder": "např. cpc, email, social", + "utmShare.campaign.label": "Kampaň", + "utmShare.campaign.placeholder": "např. jarni_vyprodej", + "utmShare.content.label": "Obsah", + "utmShare.content.placeholder": "např. logo_odkaz", + "utmShare.term.label": "Výraz", + "utmShare.term.placeholder": "např. běžecké boty", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "např. getkirby.com", + "ai.action.generate": "Vygenerovat pomocí AI", + "ai.action.regenerate": "Vygenerovat znovu", + "ai.action.edit": "Upravit…", + "ai.action.customize": "Přizpůsobit generování AI…", + "ai.action.stop": "Zastavit", + "ai.error.request": "Požadavek na AI selhal. Zkus to prosím znovu.", + "ai.error.disabled": "Funkce AI jsou vypnuté.", + "ai.error.permission": "Nemáš oprávnění používat funkce AI.", + "ai.dialog.instructions.label": "Pokyny", + "ai.dialog.instructions.placeholder": "Jaké změny chceš v textu provést?", + "ai.dialog.edit.submit": "Použít změny", + "ai.dialog.custom.label": "Vlastní pokyny", + "ai.dialog.custom.placeholder": "Jaký typ obsahu chceš vygenerovat?", + "ai.dialog.custom.submit": "Vygenerovat", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Nastav přihlašovací údaje Google Cloud pro připojení Search Console. Instrukce k nastavení najdeš v dokumentaci.", + "sections.searchConsole.notConnected": "Připoj svůj účet Google, abys viděla vyhledávací data pro tuto stránku.", + "sections.searchConsole.selectProperty": "Vyber, kterou vlastnost Search Console chceš použít.", + "sections.searchConsole.selectPropertyButton": "Vybrat vlastnost", + "sections.searchConsole.selectPropertyLabel": "Vlastnost", + "sections.searchConsole.scDomain": "doména", + "sections.searchConsole.docs": "Dokumentace", + "sections.searchConsole.connect": "Připojit", + "sections.searchConsole.reconnect": "Připojit znovu", + "sections.searchConsole.noData": "Pro tuto stránku nejsou k dispozici žádná vyhledávací data.", + "sections.searchConsole.showMore": "Zobrazit vše", + "sections.searchConsole.sortBy": "Seřadit podle", + "sections.searchConsole.query": "Dotaz", + "sections.searchConsole.clicks": "Kliknutí", + "sections.searchConsole.impressions": "Zobrazení", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Pozice", + "sections.searchConsole.openInGsc": "Otevřít v Search Console" +} diff --git a/site/plugins/kirby-seo/translations/de.json b/site/plugins/kirby-seo/translations/de.json new file mode 100644 index 0000000..ad56eac --- /dev/null +++ b/site/plugins/kirby-seo/translations/de.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Überschriftenstruktur", + "sections.headingStructure.errors.incorrectOrder": "Deine Überschriftenstruktur hat eine falsche Abfolge und ist ungültig.", + "sections.headingStructure.errors.missingH1": "Deine Überschriftenstruktur enthält keine H1 und ist ungültig.", + "sections.headingStructure.errors.multipleH1": "Deine Überschriftenstruktur enthält mehr als eine H1 und ist ungültig.", + "sections.preview.title": "Vorschau", + "sections.preview.titleWithPage": "Vorschau (zeigt \"{title}\")", + "sections.preview.viewPage": "Seite ansehen", + "sections.preview.showFor": "Zeige mir", + "sections.preview.openDebugger": "Sharing-Debugger öffnen", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexierung erlaubt", + "fields.robots.indicator.any": "Indexierung teilw. verboten", + "fields.robots.indicator.noindex": "Indexierung verboten", + "fields.robots.label": "Richtlinien für Suchmaschinen & Crawler", + "fields.robots.index.label": "Indexierung", + "fields.robots.index.help": "Ob Suchmaschinen die Seite indexieren dürfen.", + "fields.robots.follow.label": "Links folgen", + "fields.robots.follow.help": "Ob Suchmaschinen Links auf dieser Seite folgen dürfen.", + "fields.robots.archive.label": "Archivierung", + "fields.robots.archive.help": "Ob Suchmaschinen zwischengespeicherte Versionen der Seite ausliefern dürfen.", + "fields.robots.imageindex.label": "Bilder-Indexierung", + "fields.robots.imageindex.help": "Ob Bilder dieser Seite in der Bildersuche angezeigt werden dürfen.", + "fields.robots.snippet.label": "Snippets", + "fields.robots.snippet.help": "Ob Suchmaschinen Textausschnitte aus der Seite anzeigen dürfen.", + "tabs.seo": "Metadaten & SEO", + "site.meta.headline": "Globale SEO-Einstellungen", + "site.meta.headline.help": "Diese Einstellungen werden für alle Seiten verwendet, die keine eigenen Metadaten haben.\nDu kannst sie für jede Seite überschreiben.", + "fields.metaTitleTemplate.label": "Titel-Template", + "fields.metaTitleTemplate.help": "Eine Vorlage für alle Seitentitel.", + "fields.metaDescription.label": "Seitenbeschreibung", + "fields.metaDescription.help": "Empfohlene Länge von max. 150 Zeichen. Wird verwendet, falls keine Seitenbeschreibung angegeben ist.", + "site.og.headline": "Globale Open Graph-Einstellungen", + "site.og.headline.help": "Stelle ein, wie deine Website erscheint, wenn sie auf sozialen Netzwerken wie Facebook oder Twitter geteilt wird.", + "fields.ogTitleTemplate.label": "Open Graph-Titel-Template", + "fields.ogDescription.label": "Open Graph-Beschreibung", + "fields.ogSiteName.label": "Open Graph-Seitenname", + "fields.ogImage.label": "Open Graph-Bild", + "fields.ogImage.help": "Empfohlene Größe von 1200x630 Pixeln.", + "fields.ogImage.empty": "Kein Open Graph-Bild ausgewählt", + "fields.cropOgImage.label": "Auf empfohlene Größe zuschneiden?", + "fields.cropOgImage.help": "Empfohlene Größe ist 1200x630px. Wenn aktiviert, werden Bilder automatisch auf diese Größe zugeschnitten für optimale Anzeige in sozialen Medien.", + "fields.socialMediaAccounts.label": "Social Media-Accounts", + "fields.socialMediaAccounts.help": "URLs bzw. @-Handles zu deinen Social Media-Accounts. Werden verwendet, um Links zu deinen Accounts in den Metadaten zu setzen.", + "page.meta.headline": "SEO-Einstellungen", + "page.og.headline": "Open Graph-Einstellungen", + "fields.titleOverwrite.label": "Titel (Überschreiben)", + "fields.inheritSettings.label": "Einstellungen vererben", + "fields.inheritSettings.help": "Wähle aus, welche Einstellungen an Unterseiten vererbt werden sollen.\nDies kann z.B. hilfreich sein, wenn alle Beiträge eines Blogs ein eigenes Titel-Template haben sollen, welches vom Seiten-Standard abweicht. Alle Einstellungen lassen sich weiterhin in der Hauptseite überschreiben.", + "fields.useTitleTemplate.label": "Titel-Template verwenden?", + "fields.useTitleTemplate.no": "Nein - reiner Titel", + "fields.useTitleTemplate.yes": "Ja - mit Template", + "fields.useTitleTemplate.help": "Gibt an, ob das Titel-Template verwendet werden soll. Wird nicht vererbt.", + "writerNodes.template.title": "Seitentitel", + "writerNodes.template.siteTitle": "Website-Titel", + "common.default": "Standard:", + "common.yes": "Ja", + "common.no": "Nein", + "sitemap.title": "Sitemap", + "sitemap.index": "Sitemap-Index", + "sitemap.description": "Dies ist die Sitemap für deine Website, die Suchmaschinen über die Seiten auf deiner Website informiert, die indexiert werden können.", + "sitemap.by": "von", + "sitemap.changefreq": "Änderungsfrequenz", + "sitemap.lastUpdated": "Letzte Änderung", + "sitemap.priority": "Priorität", + "sitemap.url": "URL", + "sitemap.noEntries": "Keine Einträge", + "utmShare.button": "Teilen", + "utmShare.parameters": "Parameter", + "utmShare.source.label": "Quelle", + "utmShare.source.placeholder": "z. B. google, newsletter", + "utmShare.medium.label": "Medium", + "utmShare.medium.placeholder": "z. B. cpc, email, social", + "utmShare.campaign.label": "Kampagne", + "utmShare.campaign.placeholder": "z. B. fruehjahrsverkauf", + "utmShare.content.label": "Inhalt", + "utmShare.content.placeholder": "z. B. logo_link", + "utmShare.term.label": "Begriff", + "utmShare.term.placeholder": "z. B. laufschuhe", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "z. B. getkirby.com", + "ai.action.generate": "Mit KI generieren", + "ai.action.regenerate": "Neu generieren", + "ai.action.edit": "Bearbeiten...", + "ai.action.customize": "KI-Generierung anpassen...", + "ai.action.stop": "Stoppen", + "ai.error.request": "Die KI-Anfrage ist fehlgeschlagen. Bitte versuche es erneut.", + "ai.error.disabled": "KI-Funktionen sind deaktiviert.", + "ai.error.permission": "Du hast keine Berechtigung, KI-Funktionen zu nutzen.", + "ai.dialog.instructions.label": "Anweisungen", + "ai.dialog.instructions.placeholder": "Welche Änderungen möchtest du am Text vornehmen?", + "ai.dialog.edit.submit": "Änderungen übernehmen", + "ai.dialog.custom.label": "Benutzerdefinierte Anweisungen", + "ai.dialog.custom.placeholder": "Welche Art von Inhalt möchtest du generieren?", + "ai.dialog.custom.submit": "Generieren", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Richte Google Cloud-Zugangsdaten ein, um die Search Console zu verbinden. Siehe die Dokumentation für Einrichtungsanweisungen.", + "sections.searchConsole.notConnected": "Verbinde dein Google-Konto, um Suchdaten für diese Seite zu sehen.", + "sections.searchConsole.selectProperty": "Wähle aus, welche Search Console-Property verwendet werden soll.", + "sections.searchConsole.selectPropertyButton": "Property auswählen", + "sections.searchConsole.selectPropertyLabel": "Property", + "sections.searchConsole.scDomain": "Domain", + "sections.searchConsole.docs": "Dokumentation", + "sections.searchConsole.connect": "Verbinden", + "sections.searchConsole.reconnect": "Erneut verbinden", + "sections.searchConsole.noData": "Keine Suchdaten für diese Seite verfügbar.", + "sections.searchConsole.showMore": "Alle anzeigen", + "sections.searchConsole.sortBy": "Sortieren nach", + "sections.searchConsole.query": "Suchanfrage", + "sections.searchConsole.clicks": "Klicks", + "sections.searchConsole.impressions": "Impressionen", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Position", + "sections.searchConsole.openInGsc": "In Search Console öffnen" +} diff --git a/site/plugins/kirby-seo/translations/en.json b/site/plugins/kirby-seo/translations/en.json new file mode 100644 index 0000000..086c7d6 --- /dev/null +++ b/site/plugins/kirby-seo/translations/en.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Heading Structure", + "sections.headingStructure.errors.incorrectOrder": "Your heading structure has an incorrect order and is invalid.", + "sections.headingStructure.errors.missingH1": "Your heading structure does not contain an H1 and is invalid.", + "sections.headingStructure.errors.multipleH1": "Your heading structure contains more than one H1 and is invalid.", + "sections.preview.title": "Preview", + "sections.preview.titleWithPage": "Preview (shows \"{title}\")", + "sections.preview.viewPage": "View page", + "sections.preview.showFor": "Show me", + "sections.preview.openDebugger": "Open Sharing Debugger", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexing allowed", + "fields.robots.indicator.any": "Indexing partly forbidden", + "fields.robots.indicator.noindex": "Indexing forbidden", + "fields.robots.label": "Robots Directives", + "fields.robots.index.label": "Indexing", + "fields.robots.index.help": "Whether search engines may index this page.", + "fields.robots.follow.label": "Follow Links", + "fields.robots.follow.help": "Whether search engines may follow links on this page.", + "fields.robots.archive.label": "Archive", + "fields.robots.archive.help": "Whether search engines may archive this page.", + "fields.robots.imageindex.label": "Image Indexing", + "fields.robots.imageindex.help": "Whether search engines may index images on this page.", + "fields.robots.snippet.label": "Snippets", + "fields.robots.snippet.help": "Whether search engines may show text snippets of this page.", + "tabs.seo": "Metadata & SEO", + "site.meta.headline": "Global SEO Settings", + "site.meta.headline.help": "These settings are used for all pages that do not have their own metadata.\nYou can override them for each page.", + "fields.metaTitleTemplate.label": "Title Template", + "fields.metaTitleTemplate.help": "A template to use for all page titles.", + "fields.metaDescription.label": "Page Description", + "fields.metaDescription.help": "Recommended length of 150 characters max. Used if no page description is specified.", + "site.og.headline": "Global Open Graph Settings", + "site.og.headline.help": "Set how your website appears when shared on social networks like Facebook or Twitter.", + "fields.ogTitleTemplate.label": "Open Graph Title Template", + "fields.ogDescription.label": "Open Graph Description", + "fields.ogSiteName.label": "Open Graph Site Name", + "fields.ogImage.label": "Open Graph Image", + "fields.ogImage.help": "Recommended size of 1200x630 pixels.", + "fields.ogImage.empty": "No Open Graph Image selected", + "fields.cropOgImage.label": "Crop OG Image to recommended size?", + "fields.cropOgImage.help": "Recommended size is 1200x630px. When enabled, images will be automatically cropped to this size for optimal display on social media.", + "fields.socialMediaAccounts.label": "Social Media Accounts", + "fields.socialMediaAccounts.help": "URLs or @handles to your social media accounts. Used to put links to your accounts in the metadata.", + "page.meta.headline": "SEO Settings", + "page.og.headline": "Open Graph Settings", + "fields.titleOverwrite.label": "Title (overwrite)", + "fields.inheritSettings.label": "Inherit Settings", + "fields.inheritSettings.help": "Select which settings should be inherited by subpages.\nThis can be helpful, for example, if all posts of a blog should have their own title template, which differs from the page default. All settings can still be overridden in the main page.", + "fields.useTitleTemplate.label": "Use title template?", + "fields.useTitleTemplate.no": "No - only title", + "fields.useTitleTemplate.yes": "Yes - with template", + "fields.useTitleTemplate.help": "Specifies whether the title template should be used. Will not be inherited.", + "writerNodes.template.title": "Page Title", + "writerNodes.template.siteTitle": "Site Title", + "common.default": "Default:", + "common.yes": "Yes", + "common.no": "No", + "sitemap.title": "Sitemap", + "sitemap.index": "Sitemap Index", + "sitemap.description": "This is the sitemap for your website that informs search engines about the pages on your website that can be indexed.", + "sitemap.by": "by", + "sitemap.changefreq": "Change Frequency", + "sitemap.lastUpdated": "Last Updated", + "sitemap.priority": "Priority", + "sitemap.url": "URL", + "sitemap.noEntries": "No entries", + "utmShare.button": "Share", + "utmShare.parameters": "Parameters", + "utmShare.source.label": "Source", + "utmShare.source.placeholder": "e.g. google, newsletter", + "utmShare.medium.label": "Medium", + "utmShare.medium.placeholder": "e.g. cpc, email, social", + "utmShare.campaign.label": "Campaign", + "utmShare.campaign.placeholder": "e.g. spring_sale", + "utmShare.content.label": "Content", + "utmShare.content.placeholder": "e.g. logo_link", + "utmShare.term.label": "Term", + "utmShare.term.placeholder": "e.g. running shoes", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "e.g. getkirby.com", + "ai.action.generate": "Generate with AI", + "ai.action.regenerate": "Regenerate", + "ai.action.edit": "Edit…", + "ai.action.customize": "Customize AI generation…", + "ai.action.stop": "Stop", + "ai.error.request": "The AI request failed. Please try again.", + "ai.error.disabled": "AI features are disabled.", + "ai.error.permission": "You do not have the permission to use AI features.", + "ai.dialog.instructions.label": "Instructions", + "ai.dialog.instructions.placeholder": "What changes do you want to make to the text?", + "ai.dialog.edit.submit": "Apply Changes", + "ai.dialog.custom.label": "Custom Instructions", + "ai.dialog.custom.placeholder": "What kind of content do you want to generate?", + "ai.dialog.custom.submit": "Generate", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Set up Google Cloud credentials to connect Search Console. See the docs for setup instructions.", + "sections.searchConsole.notConnected": "Connect your Google account to see search data for this page.", + "sections.searchConsole.selectProperty": "Select which Search Console property to use.", + "sections.searchConsole.selectPropertyButton": "Select Property", + "sections.searchConsole.selectPropertyLabel": "Property", + "sections.searchConsole.scDomain": "domain", + "sections.searchConsole.docs": "Docs", + "sections.searchConsole.connect": "Connect", + "sections.searchConsole.reconnect": "Reconnect", + "sections.searchConsole.noData": "No search data available for this page.", + "sections.searchConsole.showMore": "Show all", + "sections.searchConsole.sortBy": "Sort by", + "sections.searchConsole.query": "Query", + "sections.searchConsole.clicks": "Clicks", + "sections.searchConsole.impressions": "Impressions", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Position", + "sections.searchConsole.openInGsc": "Open in Search Console" +} diff --git a/site/plugins/kirby-seo/translations/fr.json b/site/plugins/kirby-seo/translations/fr.json new file mode 100644 index 0000000..70d6cf4 --- /dev/null +++ b/site/plugins/kirby-seo/translations/fr.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Structure des titres", + "sections.headingStructure.errors.incorrectOrder": "Votre structure de titres a un ordre incorrect et est invalide.", + "sections.headingStructure.errors.missingH1": "Votre structure de titres ne contient pas de balise H1 et est invalide.", + "sections.headingStructure.errors.multipleH1": "Votre structure de titres contient plus d'une balise H1 et est invalide.", + "sections.preview.title": "Aperçu", + "sections.preview.titleWithPage": "Aperçu (affiche « {title} »)", + "sections.preview.viewPage": "Voir la page", + "sections.preview.showFor": "Montre-moi", + "sections.preview.openDebugger": "Ouvrir le débogueur de partage", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexation autorisée", + "fields.robots.indicator.any": "Indexation partiellement interdite", + "fields.robots.indicator.noindex": "Indexation interdite", + "fields.robots.label": "Directives des robots", + "fields.robots.index.label": "Indexation", + "fields.robots.index.help": "Indique si les moteurs de recherche peuvent indexer cette page.", + "fields.robots.follow.label": "Suivre les liens", + "fields.robots.follow.help": "Indique si les moteurs de recherche peuvent suivre les liens de cette page.", + "fields.robots.archive.label": "Archiver", + "fields.robots.archive.help": "Indique si les moteurs de recherche peuvent archiver cette page.", + "fields.robots.imageindex.label": "Indexation des images", + "fields.robots.imageindex.help": "Indique si les moteurs de recherche peuvent indexer les images de cette page.", + "fields.robots.snippet.label": "Extraits", + "fields.robots.snippet.help": "Indique si les moteurs de recherche peuvent afficher des extraits de texte de cette page.", + "tabs.seo": "Métadonnées & SEO", + "site.meta.headline": "Paramètres SEO globaux", + "site.meta.headline.help": "Ces paramètres sont utilisés pour toutes les pages qui n'ont pas leurs propres métadonnées.\nVous pouvez les remplacer pour chaque page.", + "fields.metaTitleTemplate.label": "Modèle de titre", + "fields.metaTitleTemplate.help": "Un modèle à utiliser pour tous les titres de page.", + "fields.metaDescription.label": "Description de la page", + "fields.metaDescription.help": "Longueur recommandée de 150 caractères maximum. Utilisée si aucune description de page n'est spécifiée.", + "site.og.headline": "Paramètres globaux Open Graph", + "site.og.headline.help": "Définissez l'apparence de votre site web lorsqu'il est partagé sur les réseaux sociaux tels que Facebook ou Twitter.", + "fields.ogTitleTemplate.label": "Modèle de titre Open Graph", + "fields.ogDescription.label": "Description Open Graph", + "fields.ogSiteName.label": "Nom du site Open Graph", + "fields.ogImage.label": "Image Open Graph", + "fields.ogImage.help": "Taille recommandée de 1200x630 pixels.", + "fields.ogImage.empty": "Aucune image Open Graph sélectionnée", + "fields.cropOgImage.label": "Recadrer l'image OG à la taille recommandée?", + "fields.cropOgImage.help": "La taille recommandée est de 1200x630px. Lorsqu'activé, les images seront automatiquement recadrées à cette taille pour un affichage optimal sur les réseaux sociaux.", + "fields.socialMediaAccounts.label": "Comptes de réseaux sociaux", + "fields.socialMediaAccounts.help": "URLs ou @nom_utilisateur de vos comptes de réseaux sociaux. Utilisés pour mettre des liens vers vos comptes dans les métadonnées.​", + "page.meta.headline": "Paramètres SEO", + "page.og.headline": "Paramètres Open Graph", + "fields.titleOverwrite.label": "Titre (remplacement)", + "fields.inheritSettings.label": "Hériter des paramètres", + "fields.inheritSettings.help": "Sélectionnez les paramètres à hériter par les sous-pages.\nCela peut être utile, par exemple, si tous les articles d'un blog doivent avoir leur propre modèle de titre, différent de celui de la page par défaut. Tous les paramètres peuvent toujours être remplacés dans la page principale.", + "fields.useTitleTemplate.label": "Utiliser le modèle de titre ?", + "fields.useTitleTemplate.no": "Non - seulement le titre", + "fields.useTitleTemplate.yes": "Oui - avec le modèle", + "fields.useTitleTemplate.help": "Indique si le modèle de titre doit être utilisé. Ne sera pas hérité.", + "writerNodes.template.title": "Titre de la page", + "writerNodes.template.siteTitle": "Titre du site", + "common.default": "Par défaut :", + "common.yes": "Oui", + "common.no": "Non", + "sitemap.title": "Sitemap", + "sitemap.index": "Index de sitemap", + "sitemap.description": "Il s'agit du sitemap de votre site web qui informe les moteurs de recherche des pages de votre site web qui peuvent être indexées.", + "sitemap.by": "par", + "sitemap.changefreq": "Fréquence de changement", + "sitemap.lastUpdated": "Dernière mise à jour", + "sitemap.priority": "Priorité", + "sitemap.url": "URL", + "sitemap.noEntries": "Aucune entrée", + "utmShare.button": "Partager", + "utmShare.parameters": "Paramètres", + "utmShare.source.label": "Source", + "utmShare.source.placeholder": "ex. google, newsletter", + "utmShare.medium.label": "Support", + "utmShare.medium.placeholder": "ex. cpc, email, social", + "utmShare.campaign.label": "Campagne", + "utmShare.campaign.placeholder": "ex. soldes_printemps", + "utmShare.content.label": "Contenu", + "utmShare.content.placeholder": "ex. lien_logo", + "utmShare.term.label": "Terme", + "utmShare.term.placeholder": "ex. chaussures de course", + "utmShare.ref.label": "Réf", + "utmShare.ref.placeholder": "ex. getkirby.com", + "ai.action.generate": "Générer avec l'IA", + "ai.action.regenerate": "Régénérer", + "ai.action.edit": "Modifier...", + "ai.action.customize": "Personnaliser la génération IA...", + "ai.action.stop": "Arrêter", + "ai.error.request": "La requête IA a échoué. Veuillez réessayer.", + "ai.error.disabled": "Les fonctionnalités d'IA sont désactivées.", + "ai.error.permission": "Vous n'avez pas la permission d'utiliser les fonctionnalités d'IA.", + "ai.dialog.instructions.label": "Instructions", + "ai.dialog.instructions.placeholder": "Quelles modifications souhaitez-vous apporter au texte ?", + "ai.dialog.edit.submit": "Appliquer les modifications", + "ai.dialog.custom.label": "Instructions personnalisées", + "ai.dialog.custom.placeholder": "Quel type de contenu souhaitez-vous générer ?", + "ai.dialog.custom.submit": "Générer", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Configure les identifiants Google Cloud pour connecter Search Console. Consulte la documentation pour les instructions de configuration.", + "sections.searchConsole.notConnected": "Connecte ton compte Google pour voir les données de recherche de cette page.", + "sections.searchConsole.selectProperty": "Sélectionne la propriété Search Console à utiliser.", + "sections.searchConsole.selectPropertyButton": "Sélectionner la propriété", + "sections.searchConsole.selectPropertyLabel": "Propriété", + "sections.searchConsole.scDomain": "domaine", + "sections.searchConsole.docs": "Documentation", + "sections.searchConsole.connect": "Connecter", + "sections.searchConsole.reconnect": "Reconnecter", + "sections.searchConsole.noData": "Aucune donnée de recherche disponible pour cette page.", + "sections.searchConsole.showMore": "Tout afficher", + "sections.searchConsole.sortBy": "Trier par", + "sections.searchConsole.query": "Requête", + "sections.searchConsole.clicks": "Clics", + "sections.searchConsole.impressions": "Impressions", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Position", + "sections.searchConsole.openInGsc": "Ouvrir dans Search Console" +} diff --git a/site/plugins/kirby-seo/translations/nl.json b/site/plugins/kirby-seo/translations/nl.json new file mode 100644 index 0000000..6edaffc --- /dev/null +++ b/site/plugins/kirby-seo/translations/nl.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Heading structuur", + "sections.headingStructure.errors.incorrectOrder": "Je heading structuur heeft een onjuiste volgorde en is ongeldig.", + "sections.headingStructure.errors.missingH1": "Je heading structuur bevat geen H1 en is ongeldig.", + "sections.headingStructure.errors.multipleH1": "Je heading structuur bevat meer dan één H1 en is ongeldig.", + "sections.preview.title": "Voorvertoning", + "sections.preview.titleWithPage": "Voorbeeld (toont \"{title}\")", + "sections.preview.viewPage": "Pagina bekijken", + "sections.preview.showFor": "Voorbeeld op", + "sections.preview.openDebugger": "Open Sharing Debugger", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexeren toegestaan", + "fields.robots.indicator.any": "Indexeren gedeeltelijk niet toegestaan", + "fields.robots.indicator.noindex": "Indexeren niet toegestaan", + "fields.robots.label": "Robots Directives", + "fields.robots.index.label": "Indexeren", + "fields.robots.index.help": "Of zoekmachines deze pagina mogen indexeren.", + "fields.robots.follow.label": "Volg Links", + "fields.robots.follow.help": "Of zoekmachines links op deze pagina mogen volgen.", + "fields.robots.archive.label": "Archiveren", + "fields.robots.archive.help": "Of zoekmachines deze pagina mogen archiveren.", + "fields.robots.imageindex.label": "Afbeeldingen indexeren", + "fields.robots.imageindex.help": "Of zoekmachines afbeeldingen op deze pagina mogen indexeren.", + "fields.robots.snippet.label": "Fragmenten", + "fields.robots.snippet.help": "Of zoekmachines tekstfragmenten van deze pagina mogen tonen.", + "tabs.seo": "Metadata & SEO", + "site.meta.headline": "Globale SEO Instellingen", + "site.meta.headline.help": "Deze instellingen worden gebruikt voor alle pagina's die geen eigen metadata hebben.\nJe kunt ze voor elke pagina overschrijven.", + "fields.metaTitleTemplate.label": "Titel template", + "fields.metaTitleTemplate.help": "Een sjabloon voor alle paginatitels.", + "fields.metaDescription.label": "Paginabeschrijving", + "fields.metaDescription.help": "Aanbevolen lengte van maximaal 150 tekens. Gebruikt als er geen paginabeschrijving is opgegeven.", + "site.og.headline": "Globale Open Graph Instellingen", + "site.og.headline.help": "Bepaal hoe je website verschijnt wanneer deze wordt gedeeld op sociale netwerken zoals Facebook of Twitter.", + "fields.ogTitleTemplate.label": "Open Graph Titel Template", + "fields.ogDescription.label": "Open Graph Beschrijving", + "fields.ogSiteName.label": "Open Graph Sitenaam", + "fields.ogImage.label": "Open Graph Afbeelding", + "fields.ogImage.help": "Aanbevolen grootte van 1200x630 pixels.", + "fields.ogImage.empty": "Geen Open Graph Afbeelding geselecteerd", + "fields.cropOgImage.label": "OG-afbeelding bijsnijden naar aanbevolen grootte?", + "fields.cropOgImage.help": "Aanbevolen grootte is 1200x630px. Indien ingeschakeld, worden afbeeldingen automatisch bijgesneden naar deze grootte voor optimale weergave op sociale media.", + "fields.socialMediaAccounts.label": "Sociale Media Accounts", + "fields.socialMediaAccounts.help": "URL's of @handles naar je sociale media accounts. Gebruikt om links naar je accounts in de metadata te plaatsen.", + "page.meta.headline": "SEO-instellingen", + "page.og.headline": "Open Graph-instellingen", + "fields.titleOverwrite.label": "Titel (overschrijven)", + "fields.inheritSettings.label": "Instellingen Overerven", + "fields.inheritSettings.help": "Selecteer welke instellingen door subpagina's moeten worden geërfd.\nDit kan nuttig zijn, bijvoorbeeld als alle berichten van een blog hun eigen titelsjabloon moeten hebben, die verschilt van de standaard van de pagina. Alle instellingen kunnen nog steeds worden overschreven op de hoofdpagina.", + "fields.useTitleTemplate.label": "Titelsjabloon gebruiken?", + "fields.useTitleTemplate.no": "Nee - alleen titel", + "fields.useTitleTemplate.yes": "Ja - met sjabloon", + "fields.useTitleTemplate.help": "Geeft aan of het titelsjabloon moet worden gebruikt. Wordt niet geërfd.", + "writerNodes.template.title": "Paginatitel", + "writerNodes.template.siteTitle": "Sitenaam", + "common.default": "Standaard:", + "common.yes": "Ja", + "common.no": "Nee", + "sitemap.title": "Sitemap", + "sitemap.index": "Sitemap Index", + "sitemap.description": "Dit is de sitemap voor je website die zoekmachines informeert over de pagina's op je website die geïndexeerd kunnen worden.", + "sitemap.by": "door", + "sitemap.changefreq": "Veranderingsfrequentie", + "sitemap.lastUpdated": "Laatst bijgewerkt", + "sitemap.priority": "Prioriteit", + "sitemap.url": "URL", + "sitemap.noEntries": "Geen vermeldingen", + "utmShare.button": "Delen", + "utmShare.parameters": "Parameters", + "utmShare.source.label": "Bron", + "utmShare.source.placeholder": "bijv. google, nieuwsbrief", + "utmShare.medium.label": "Medium", + "utmShare.medium.placeholder": "bijv. cpc, email, social", + "utmShare.campaign.label": "Campagne", + "utmShare.campaign.placeholder": "bijv. lente_uitverkoop", + "utmShare.content.label": "Content", + "utmShare.content.placeholder": "bijv. logo_link", + "utmShare.term.label": "Zoekterm", + "utmShare.term.placeholder": "bijv. hardloopschoenen", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "bijv. getkirby.com", + "ai.action.generate": "Genereer met AI", + "ai.action.regenerate": "Opnieuw genereren", + "ai.action.edit": "Bewerken...", + "ai.action.customize": "AI-generatie aanpassen...", + "ai.action.stop": "Stoppen", + "ai.error.request": "Het AI-verzoek is mislukt. Probeer het opnieuw.", + "ai.error.disabled": "AI-functies zijn uitgeschakeld.", + "ai.error.permission": "Je hebt geen toestemming om AI-functies te gebruiken.", + "ai.dialog.instructions.label": "Instructies", + "ai.dialog.instructions.placeholder": "Welke wijzigingen wil je aanbrengen in de tekst?", + "ai.dialog.edit.submit": "Wijzigingen toepassen", + "ai.dialog.custom.label": "Aangepaste instructies", + "ai.dialog.custom.placeholder": "Wat voor soort content wil je genereren?", + "ai.dialog.custom.submit": "Genereren", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Stel Google Cloud-inloggegevens in om Search Console te verbinden. Bekijk de documentatie voor installatie-instructies.", + "sections.searchConsole.notConnected": "Verbind je Google-account om zoekgegevens voor deze pagina te bekijken.", + "sections.searchConsole.selectProperty": "Selecteer welke Search Console-property je wilt gebruiken.", + "sections.searchConsole.selectPropertyButton": "Selecteer property", + "sections.searchConsole.selectPropertyLabel": "Property", + "sections.searchConsole.scDomain": "domein", + "sections.searchConsole.docs": "Documentatie", + "sections.searchConsole.connect": "Verbinden", + "sections.searchConsole.reconnect": "Opnieuw verbinden", + "sections.searchConsole.noData": "Geen zoekgegevens beschikbaar voor deze pagina.", + "sections.searchConsole.showMore": "Alles tonen", + "sections.searchConsole.sortBy": "Sorteer op", + "sections.searchConsole.query": "Zoekopdracht", + "sections.searchConsole.clicks": "Klikken", + "sections.searchConsole.impressions": "Vertoningen", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Positie", + "sections.searchConsole.openInGsc": "Openen in Search Console" +} diff --git a/site/plugins/kirby-seo/translations/pt_PT.json b/site/plugins/kirby-seo/translations/pt_PT.json new file mode 100644 index 0000000..37e347c --- /dev/null +++ b/site/plugins/kirby-seo/translations/pt_PT.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Estrutura de Títulos", + "sections.headingStructure.errors.incorrectOrder": "A estrutura de títulos tem uma ordem incorrecta e é inválida.", + "sections.headingStructure.errors.missingH1": "A estrutura de títulos não contém uma tag H1 e é inválida.", + "sections.headingStructure.errors.multipleH1": "A estrutura de títulos contém mais do que uma tag H1 e é inválida.", + "sections.preview.title": "Pré-visualização", + "sections.preview.titleWithPage": "Pré-visualização (mostra \"{title}\")", + "sections.preview.viewPage": "Ver página", + "sections.preview.showFor": "Mostrar", + "sections.preview.openDebugger": "Abrir Sharing Debugger", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexação permitida", + "fields.robots.indicator.any": "Indexação parcialmente proibida", + "fields.robots.indicator.noindex": "Indexação proibida", + "fields.robots.label": "Diretivas Robots", + "fields.robots.index.label": "Indexação", + "fields.robots.index.help": "Se os motores de pesquisa podem indexar esta página.", + "fields.robots.follow.label": "Seguir Links", + "fields.robots.follow.help": "Se os motores de pesquisa podem seguir links nesta página.", + "fields.robots.archive.label": "Arquivo", + "fields.robots.archive.help": "Se os motores de pesquisa podem arquivar esta página.", + "fields.robots.imageindex.label": "Indexação de Imagens", + "fields.robots.imageindex.help": "Se os motores de pesquisa podem indexar imagens desta página.", + "fields.robots.snippet.label": "Snippets", + "fields.robots.snippet.help": "Se os motores de pesquisa podem mostrar snippets de texto desta página.", + "tabs.seo": "Metadados & SEO", + "site.meta.headline": "Configurações Globais SEO", + "site.meta.headline.help": "Estas configurações são usadas para todas as páginas que não têm os seus próprios metadados.\nPode substituí-las em cada página.", + "fields.metaTitleTemplate.label": "Template de Título", + "fields.metaTitleTemplate.help": "Um modelo para usar em todos os títulos de página.", + "fields.metaDescription.label": "Descrição de Página", + "fields.metaDescription.help": "Recomendado um tamanho de 150 caracteres no máximo. Usada se nenhuma descrição de página for especificada.", + "site.og.headline": "Configurações Globais Open Graph", + "site.og.headline.help": "Defina como o seu site aparece quando é partilhado em redes sociais como o Facebook ou o Twitter.", + "fields.ogTitleTemplate.label": "Template de Título Open Graph", + "fields.ogDescription.label": "Descrição Open Graph", + "fields.ogSiteName.label": "Nome do Site Open Graph", + "fields.ogImage.label": "Imagem Open Graph", + "fields.ogImage.help": "Tamanho recomendado de 1200x630 pixels.", + "fields.ogImage.empty": "Nenhuma Imagem Open Graph selecionada", + "fields.cropOgImage.label": "Cortar imagem OG para tamanho recomendado?", + "fields.cropOgImage.help": "O tamanho recomendado é 1200x630px. Quando ativado, as imagens serão automaticamente cortadas para este tamanho para exibição ideal em redes sociais.", + "fields.socialMediaAccounts.label": "Contas de Redes Sociais", + "fields.socialMediaAccounts.help": "URLs ou @handles para as suas contas de redes sociais. Usado para colocar links para as suas contas nos metadados.", + "page.meta.headline": "Definições de SEO", + "page.og.headline": "Definições de Open Graph", + "fields.titleOverwrite.label": "Título (substituir)", + "fields.inheritSettings.label": "Herdar Configurações", + "fields.inheritSettings.help": "Selecione quais as configurações que devem ser herdadas pelas subpáginas.\nIsto pode ser útil, por exemplo, se todos os posts de um blog tiverem o seu próprio template de título, que pode ser diferente do pré-configurado na página. Todas as configurações continuam a poder ser substituídas na página principal.", + "fields.useTitleTemplate.label": "Usar o template de título?", + "fields.useTitleTemplate.no": "Não - apenas o título", + "fields.useTitleTemplate.yes": "Sim - com template", + "fields.useTitleTemplate.help": "Especifica se o template de título deve ser usado. Não será herdado.", + "writerNodes.template.title": "Título da página", + "writerNodes.template.siteTitle": "Título do site", + "common.default": "Por defeito:", + "common.yes": "Sim", + "common.no": "Não", + "sitemap.title": "Sitemap", + "sitemap.index": "Índice Sitemap", + "sitemap.description": "Este é o sitemap do site que informa os motores de pesquisa sobre as páginas que podem ser indexadas.", + "sitemap.by": "por", + "sitemap.changefreq": "Frequência de Mudança", + "sitemap.lastUpdated": "Última Atualização", + "sitemap.priority": "Prioridade", + "sitemap.url": "URL", + "sitemap.noEntries": "Sem registos", + "utmShare.button": "Partilhar", + "utmShare.parameters": "Parâmetros", + "utmShare.source.label": "Origem", + "utmShare.source.placeholder": "ex: google, newsletter", + "utmShare.medium.label": "Meio", + "utmShare.medium.placeholder": "ex: cpc, email, social", + "utmShare.campaign.label": "Campanha", + "utmShare.campaign.placeholder": "ex: saldos_primavera", + "utmShare.content.label": "Conteúdo", + "utmShare.content.placeholder": "ex: link_logotipo", + "utmShare.term.label": "Termo", + "utmShare.term.placeholder": "ex: ténis de corrida", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "ex: getkirby.com", + "ai.action.generate": "Gerar com IA", + "ai.action.regenerate": "Regenerar", + "ai.action.edit": "Editar...", + "ai.action.customize": "Personalizar geração de IA...", + "ai.action.stop": "Parar", + "ai.error.request": "O pedido de IA falhou. Por favor, tenta novamente.", + "ai.error.disabled": "As funcionalidades de IA estão desativadas.", + "ai.error.permission": "Não tens permissão para usar as funcionalidades de IA.", + "ai.dialog.instructions.label": "Instruções", + "ai.dialog.instructions.placeholder": "Que alterações queres fazer ao texto?", + "ai.dialog.edit.submit": "Aplicar alterações", + "ai.dialog.custom.label": "Instruções personalizadas", + "ai.dialog.custom.placeholder": "Que tipo de conteúdo queres gerar?", + "ai.dialog.custom.submit": "Gerar", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Configura as credenciais do Google Cloud para conectar a Search Console. Consulta a documentação para instruções de configuração.", + "sections.searchConsole.notConnected": "Conecta a tua conta Google para veres os dados de pesquisa desta página.", + "sections.searchConsole.selectProperty": "Seleciona qual propriedade da Search Console queres usar.", + "sections.searchConsole.selectPropertyButton": "Selecionar propriedade", + "sections.searchConsole.selectPropertyLabel": "Propriedade", + "sections.searchConsole.scDomain": "domínio", + "sections.searchConsole.docs": "Documentação", + "sections.searchConsole.connect": "Conectar", + "sections.searchConsole.reconnect": "Reconectar", + "sections.searchConsole.noData": "Não há dados de pesquisa disponíveis para esta página.", + "sections.searchConsole.showMore": "Mostrar tudo", + "sections.searchConsole.sortBy": "Ordenar por", + "sections.searchConsole.query": "Consulta", + "sections.searchConsole.clicks": "Cliques", + "sections.searchConsole.impressions": "Impressões", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Posição", + "sections.searchConsole.openInGsc": "Abrir na Search Console" +} diff --git a/site/plugins/kirby-seo/translations/ro.json b/site/plugins/kirby-seo/translations/ro.json new file mode 100644 index 0000000..5320502 --- /dev/null +++ b/site/plugins/kirby-seo/translations/ro.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Structura de subtitluri", + "sections.headingStructure.errors.incorrectOrder": "Structura de subtitluri are ordinea incorectă, ceea ce o face invalidă.", + "sections.headingStructure.errors.missingH1": "Structura de subtitluri nu conține un H1, ceea ce o face invalidă.", + "sections.headingStructure.errors.multipleH1": "Structura de subtitluri conține mai mult de un H1, ceea ce o face invalidă.", + "sections.preview.title": "Previzualizare", + "sections.preview.titleWithPage": "Previzualizare (afișează „{title}\")", + "sections.preview.viewPage": "Vezi pagina", + "sections.preview.showFor": "Arată-mi", + "sections.preview.openDebugger": "Deschide Sharing Debugger", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexarea permisă", + "fields.robots.indicator.any": "Indexarea parțial interzisă", + "fields.robots.indicator.noindex": "Indexarea interzisă", + "fields.robots.label": "Directive Robots", + "fields.robots.index.label": "Indexare", + "fields.robots.index.help": "Dacă se permite motoarelor de căutare să indexeze această pagină.", + "fields.robots.follow.label": "Urmare linkuri", + "fields.robots.follow.help": "Dacă se permite motoarelor de căutare să urmeze linkurile de pe această pagină.", + "fields.robots.archive.label": "Arhivare", + "fields.robots.archive.help": "Dacă se permite motoarelor de căutare să arhiveze această pagină.", + "fields.robots.imageindex.label": "Indexare imagini", + "fields.robots.imageindex.help": "Dacă se permite motoarelor de căutare să indexeze imaginile de pe această pagină.", + "fields.robots.snippet.label": "Fragmente", + "fields.robots.snippet.help": "Dacă se permite motoarelor de căutare să afișeze fragmente din această pagină.", + "tabs.seo": "Metadata și SEO", + "site.meta.headline": "Setări globale SEO", + "site.meta.headline.help": "Aceste setări sunt folosite pentru toate paginile care nu au metadata proprie.\nEle se pot suprascrie pentru fiecare pagină în parte.", + "fields.metaTitleTemplate.label": "Șablon pentru titlu", + "fields.metaTitleTemplate.help": "Șablonul implicit folosit pentru toate paginile.", + "fields.metaDescription.label": "Descrierea paginii", + "fields.metaDescription.help": "Lungimea recomandată este de maxim 150 de caractere. Folosită dacă o pagină nu are propria descriere specificată.", + "site.og.headline": "Setări globale Open Graph", + "site.og.headline.help": "Stabilește cum apare website-ul atunci când este partajat pe rețelele sociale ca Facebook sau Twitter.", + "fields.ogTitleTemplate.label": "Șablon pentru titlu Open Graph", + "fields.ogDescription.label": "Descriere Open Graph", + "fields.ogSiteName.label": "Nume site Open Graph", + "fields.ogImage.label": "Imagine Open Graph", + "fields.ogImage.help": "Dimensiunea recomandată este de 1200x630 pixeli.", + "fields.ogImage.empty": "Nicio imagine Open Graph aleasă", + "fields.cropOgImage.label": "Decupează imaginea OG la dimensiunea recomandată?", + "fields.cropOgImage.help": "Dimensiunea recomandată este de 1200x630px. Când setarea este activă, imaginile vor fi decupate automat la această dimensiune pentru o afișare ideală pe rețelele sociale.", + "fields.socialMediaAccounts.label": "Conturi sociale", + "fields.socialMediaAccounts.help": "URL-uri sau @username-uri către conturile tale pe rețelele sociale. Folosite pentru a pune linkuri către aceste conturi în metadata.", + "page.meta.headline": "Setări SEO", + "page.og.headline": "Setări Open Graph", + "fields.titleOverwrite.label": "Titlu (suprascrie)", + "fields.inheritSettings.label": "Moștenește setări", + "fields.inheritSettings.help": "Alege ce setări să moștenească subpaginile.\nPoate fi util când, de exemplu, toate postările unui blog folosesc un șablon de titlu comun, dar care diferă de șablonul implicit. Setările pot fi suprascrise oricând în subpagină.", + "fields.useTitleTemplate.label": "Folosește șablon pentru titlu?", + "fields.useTitleTemplate.no": "Nu - doar titlul", + "fields.useTitleTemplate.yes": "Da - cu șablon", + "fields.useTitleTemplate.help": "Dacă să se folosească șablonul de titlu. Nu se moștenește.", + "writerNodes.template.title": "Titlul paginii", + "writerNodes.template.siteTitle": "Titlul website-ului", + "common.default": "Implicit:", + "common.yes": "Da", + "common.no": "Nu", + "sitemap.title": "Sitemap", + "sitemap.index": "Index sitemap-uri", + "sitemap.description": "Acesta este sitemap-ul care informează motoarele de căutare despre paginile din website care pot fi indexate.", + "sitemap.by": "de", + "sitemap.changefreq": "Schimbă frecvența", + "sitemap.lastUpdated": "Ultima actualizare", + "sitemap.priority": "Prioritate", + "sitemap.url": "URL", + "sitemap.noEntries": "Nicio înregistrare", + "utmShare.button": "Distribuie", + "utmShare.parameters": "Parametri", + "utmShare.source.label": "Sursă", + "utmShare.source.placeholder": "ex: google, newsletter", + "utmShare.medium.label": "Mediu", + "utmShare.medium.placeholder": "ex: cpc, email, social", + "utmShare.campaign.label": "Campanie", + "utmShare.campaign.placeholder": "ex: spring_sale", + "utmShare.content.label": "Conținut", + "utmShare.content.placeholder": "ex: logo_link", + "utmShare.term.label": "Termen", + "utmShare.term.placeholder": "ex: pantofi de alergare", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "ex: getkirby.com", + "ai.action.generate": "Generează cu AI", + "ai.action.regenerate": "Regenerare", + "ai.action.edit": "Editează…", + "ai.action.customize": "Personalizează generarea AI…", + "ai.action.stop": "Oprește", + "ai.error.request": "Solicitarea AI a eșuat. Te rugăm să încerci din nou.", + "ai.error.disabled": "Funcțiile AI sunt dezactivate.", + "ai.error.permission": "Nu ai permisiunea de a utiliza funcțiile AI.", + "ai.dialog.instructions.label": "Instrucțiuni", + "ai.dialog.instructions.placeholder": "Ce modificări dorești să faci textului?", + "ai.dialog.edit.submit": "Aplică modificările", + "ai.dialog.custom.label": "Instrucțiuni personalizate", + "ai.dialog.custom.placeholder": "Ce tip de conținut dorești să generezi?", + "ai.dialog.custom.submit": "Generează", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Configurează acreditările Google Cloud pentru a conecta Search Console. Vezi documentația pentru instrucțiuni de configurare.", + "sections.searchConsole.notConnected": "Conectează-ți contul Google ca să vezi datele de căutare pentru această pagină.", + "sections.searchConsole.selectProperty": "Selectează ce proprietate Search Console vrei să folosești.", + "sections.searchConsole.selectPropertyButton": "Selectează proprietatea", + "sections.searchConsole.selectPropertyLabel": "Proprietate", + "sections.searchConsole.scDomain": "domeniu", + "sections.searchConsole.docs": "Documentație", + "sections.searchConsole.connect": "Conectează", + "sections.searchConsole.reconnect": "Reconectează", + "sections.searchConsole.noData": "Nu există date de căutare disponibile pentru această pagină.", + "sections.searchConsole.showMore": "Afișează tot", + "sections.searchConsole.sortBy": "Sortează după", + "sections.searchConsole.query": "Interogare", + "sections.searchConsole.clicks": "Clickuri", + "sections.searchConsole.impressions": "Afișări", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Poziție", + "sections.searchConsole.openInGsc": "Deschide în Search Console" +} diff --git a/site/plugins/kirby-seo/translations/sv_SE.json b/site/plugins/kirby-seo/translations/sv_SE.json new file mode 100644 index 0000000..99c40c8 --- /dev/null +++ b/site/plugins/kirby-seo/translations/sv_SE.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Rubrikstruktur", + "sections.headingStructure.errors.incorrectOrder": "Din rubrikstruktur har en felaktig ordning och är ogiltig.", + "sections.headingStructure.errors.missingH1": "Din rubrikstruktur innehåller ingen H1 och är ogiltig.", + "sections.headingStructure.errors.multipleH1": "Din rubrikstruktur innehåller mer än en H1 och är ogiltig.", + "sections.preview.title": "Förhandsvisning", + "sections.preview.titleWithPage": "Förhandsgranskning (visar \"{title}\")", + "sections.preview.viewPage": "Visa sida", + "sections.preview.showFor": "Visa mig", + "sections.preview.openDebugger": "Öppna Sharing Debugger", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "Indexering tillåten", + "fields.robots.indicator.any": "Indexering delvis förbjuden", + "fields.robots.indicator.noindex": "Indexering förbjuden", + "fields.robots.label": "Robotdirektiv", + "fields.robots.index.label": "Indexering", + "fields.robots.index.help": "Om sökmotorer får indexera den här sidan.", + "fields.robots.follow.label": "Följ länkar", + "fields.robots.follow.help": "Om sökmotorer får följa länkar på den här sidan.", + "fields.robots.archive.label": "Arkiv", + "fields.robots.archive.help": "Om sökmotorer får arkivera den här sidan.", + "fields.robots.imageindex.label": "Bildindexering", + "fields.robots.imageindex.help": "Om sökmotorer får indexera bilder på den här sidan.", + "fields.robots.snippet.label": "Textutdrag", + "fields.robots.snippet.help": "Om sökmotorer får visa textutdrag från den här sidan.", + "tabs.seo": "Metadata och SEO", + "site.meta.headline": "Globala SEO-inställningar", + "site.meta.headline.help": "Dessa inställningar används för alla sidor som inte har egna metadata.\nDu kan åsidosätta dem för varje sida.", + "fields.metaTitleTemplate.label": "Titelmall", + "fields.metaTitleTemplate.help": "En mall att använda för alla sidtitlar.", + "fields.metaDescription.label": "Sidbeskrivning", + "fields.metaDescription.help": "Rekommenderad längd på max 150 tecken. Används om ingen sidbeskrivning anges.", + "site.og.headline": "Globala Open Graph-inställningar", + "site.og.headline.help": "Ställ in hur din webbplats visas när den delas på sociala nätverk som Facebook eller Twitter.", + "fields.ogTitleTemplate.label": "Open Graph titelmall", + "fields.ogDescription.label": "Open Graph beskrivning", + "fields.ogSiteName.label": "Open Graph webbplatsnamn", + "fields.ogImage.label": "Open Graph bild", + "fields.ogImage.help": "Rekommenderad storlek på 1200x630 pixlar.", + "fields.ogImage.empty": "Ingen Open Graph-bild har valts", + "fields.cropOgImage.label": "Beskär OG-bild till rekommenderad storlek?", + "fields.cropOgImage.help": "Rekommenderad storlek är 1200x630px. När aktiverad kommer bilder automatiskt beskäras till denna storlek för optimal visning på sociala medier.", + "fields.socialMediaAccounts.label": "Konton för sociala medier", + "fields.socialMediaAccounts.help": "URL:er eller @användarnamn till dina sociala mediekonton. Används för att lägga länkar till dina konton i metadata.", + "page.meta.headline": "SEO-inställningar", + "page.og.headline": "Open Graph-inställningar", + "fields.titleOverwrite.label": "Titel (skriv över)", + "fields.inheritSettings.label": "Ärv inställningar", + "fields.inheritSettings.help": "Välj vilka inställningar som ska ärvas av undersidor.\nDetta kan till exempel vara användbart om alla inlägg på en blogg ska ha en egen titelmall, som skiljer sig från sidans standard. Alla inställningar kan fortfarande åsidosättas på huvudsidan.", + "fields.useTitleTemplate.label": "Använd titelmall?", + "fields.useTitleTemplate.no": "Nej - bara titel", + "fields.useTitleTemplate.yes": "Ja - med mall", + "fields.useTitleTemplate.help": "Anger om titelmallen ska användas. Kommer inte att ärvas.", + "writerNodes.template.title": "Sidtitel", + "writerNodes.template.siteTitle": "Webbplatstitel", + "common.default": "Standard:", + "common.yes": "Ja", + "common.no": "Nej", + "sitemap.title": "Webbplatskarta", + "sitemap.index": "Webbplatskartans index", + "sitemap.description": "Detta är webbplatskartan för din webbplats som informerar sökmotorer om vilka sidor på din webbplats som kan indexeras.", + "sitemap.by": "av", + "sitemap.changefreq": "Ändra frekvens", + "sitemap.lastUpdated": "Senast uppdaterad", + "sitemap.priority": "Prioritet", + "sitemap.url": "URL", + "sitemap.noEntries": "Inga poster", + "utmShare.button": "Dela", + "utmShare.parameters": "Parametrar", + "utmShare.source.label": "Källa", + "utmShare.source.placeholder": "t.ex. google, nyhetsbrev", + "utmShare.medium.label": "Medium", + "utmShare.medium.placeholder": "t.ex. cpc, e-post, sociala medier", + "utmShare.campaign.label": "Kampanj", + "utmShare.campaign.placeholder": "t.ex. spring_sale", + "utmShare.content.label": "Innehåll", + "utmShare.content.placeholder": "t.ex. logo_link", + "utmShare.term.label": "Sökord", + "utmShare.term.placeholder": "t.ex. löparskor", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "t.ex. getkirby.com", + "ai.action.generate": "Generera med AI", + "ai.action.regenerate": "Generera om", + "ai.action.edit": "Redigera…", + "ai.action.customize": "Anpassa AI-generering…", + "ai.action.stop": "Stoppa", + "ai.error.request": "AI-förfrågan misslyckades. Försök igen.", + "ai.error.disabled": "AI-funktioner är inaktiverade.", + "ai.error.permission": "Du har inte behörighet att använda AI-funktioner.", + "ai.dialog.instructions.label": "Instruktioner", + "ai.dialog.instructions.placeholder": "Vilka ändringar vill du göra i texten?", + "ai.dialog.edit.submit": "Tillämpa ändringar", + "ai.dialog.custom.label": "Anpassade instruktioner", + "ai.dialog.custom.placeholder": "Vilken typ av innehåll vill du generera?", + "ai.dialog.custom.submit": "Generera", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Ställ in Google Cloud-referenser för att ansluta Search Console. Se dokumentationen för installationsinstruktioner.", + "sections.searchConsole.notConnected": "Anslut ditt Google-konto för att se sökdata för den här sidan.", + "sections.searchConsole.selectProperty": "Välj vilken Search Console-egenskap du vill använda.", + "sections.searchConsole.selectPropertyButton": "Välj egenskap", + "sections.searchConsole.selectPropertyLabel": "Egenskap", + "sections.searchConsole.scDomain": "domän", + "sections.searchConsole.docs": "Dokumentation", + "sections.searchConsole.connect": "Anslut", + "sections.searchConsole.reconnect": "Anslut igen", + "sections.searchConsole.noData": "Ingen sökdata tillgänglig för den här sidan.", + "sections.searchConsole.showMore": "Visa alla", + "sections.searchConsole.sortBy": "Sortera efter", + "sections.searchConsole.query": "Sökfråga", + "sections.searchConsole.clicks": "Klick", + "sections.searchConsole.impressions": "Visningar", + "sections.searchConsole.ctr": "CTR", + "sections.searchConsole.position": "Position", + "sections.searchConsole.openInGsc": "Öppna i Search Console" +} diff --git a/site/plugins/kirby-seo/translations/tr.json b/site/plugins/kirby-seo/translations/tr.json new file mode 100644 index 0000000..ba071b9 --- /dev/null +++ b/site/plugins/kirby-seo/translations/tr.json @@ -0,0 +1,117 @@ +{ + "sections.headingStructure.title": "Başlık Yapısı", + "sections.headingStructure.errors.incorrectOrder": "Başlık yapınız yanlış bir sıraya sahip ve geçersizdir.", + "sections.headingStructure.errors.missingH1": "Başlık yapınızda bir H1 etiketi bulunmuyor ve geçersizdir.", + "sections.headingStructure.errors.multipleH1": "Başlık yapınızda birden fazla H1 etiketi bulunuyor ve geçersizdir.", + "sections.preview.title": "Önizleme", + "sections.preview.titleWithPage": "Önizleme (\"{title}\" gösteriliyor)", + "sections.preview.viewPage": "Sayfayı görüntüle", + "sections.preview.showFor": "Bana göster", + "sections.preview.openDebugger": "Paylaşım Hata Ayıklayıcıyı Aç", + "sections.preview.google": "Google", + "sections.preview.facebook": "Facebook", + "sections.preview.slack": "Slack", + "fields.robots.indicator.index": "İndekslemeye izin verildi", + "fields.robots.indicator.any": "İndeksleme kısmen yasaklandı", + "fields.robots.indicator.noindex": "İndeksleme yasaklandı", + "fields.robots.label": "Robot Talimatları", + "fields.robots.index.label": "İndeksleme", + "fields.robots.index.help": "Arama motorlarının bu sayfayı indeksleyip indekslemeyeceğini belirtir.", + "fields.robots.follow.label": "Bağlantıları Takip Et", + "fields.robots.follow.help": "Arama motorlarının bu sayfadaki bağlantıları takip edip etmeyeceğini belirtir.", + "fields.robots.archive.label": "Arşivle", + "fields.robots.archive.help": "Arama motorlarının bu sayfayı arşivleyip arşivlemeyeceğini belirtir.", + "fields.robots.imageindex.label": "İmaj İndeksleme", + "fields.robots.imageindex.help": "Arama motorlarının bu sayfadaki görüntüleri indeksleyip indekslemeyeceğini belirtir.", + "fields.robots.snippet.label": "Özetler", + "fields.robots.snippet.help": "Arama motorlarının bu sayfanın metin özetlerini gösterip göstermeyeceğini belirtir.", + "tabs.seo": "Meta Veriler & SEO", + "site.meta.headline": "Genel SEO Ayarları", + "site.meta.headline.help": "Bu ayarlar, kendi meta verileri olmayan tüm sayfalar için kullanılır.\nHer sayfa için bunları geçersiz kılabilirsiniz.", + "fields.metaTitleTemplate.label": "Başlık Şablonu", + "fields.metaTitleTemplate.help": "Tüm sayfa başlıkları için kullanılacak bir şablon.", + "fields.metaDescription.label": "Sayfa Açıklaması", + "fields.metaDescription.help": "Maksimum 150 karakter uzunluğunda önerilen bir sayfa açıklamasıdır. Sayfa açıklaması belirtilmemişse kullanılır.", + "site.og.headline": "Genel Açık Grafik (OG) Ayarları", + "site.og.headline.help": "Web sitenizin Facebook veya Twitter gibi sosyal ağlarda paylaşıldığında nasıl göründüğünü ayarlar.", + "fields.ogTitleTemplate.label": "Açık Grafik (OG) Başlık Şablonu", + "fields.ogDescription.label": "Açık Grafik (OG) Açıklaması", + "fields.ogSiteName.label": "Açık Grafik (OG) Site Adı", + "fields.ogImage.label": "Açık Grafik (OG) Görseli", + "fields.ogImage.help": "Önerilen boyut 1200x630 pikseldir.", + "fields.ogImage.empty": "Boş Açık Grafik (OG) Görseli", + "fields.cropOgImage.label": "OG görselini önerilen boyuta kırp?", + "fields.cropOgImage.help": "Önerilen boyut 1200x630px'dir. Etkinleştirildiğinde, sosyal medyada en iyi görüntü için görseller otomatik olarak bu boyuta kırpılacaktır.", + "fields.socialMediaAccounts.label": "Sosyal Medya Hesapları", + "fields.socialMediaAccounts.help": "Sosyal medya hesaplarınızın URL'leri veya @kullanici_adi. Meta verilerinde hesaplarınıza bağlantı eklemek için kullanılır.", + "page.meta.headline": "SEO Ayarları", + "page.og.headline": "Open Graph Ayarları", + "fields.titleOverwrite.label": "Başlık (üzerine yaz)", + "fields.inheritSettings.label": "Ayarları Miras Al", + "fields.inheritSettings.help": "Alt sayfalar tarafından miras alınacak ayarları seçin.\nÖrneğin, bir blogun tüm yazılarının sayfa varsayılanından farklı bir başlık şablonuna sahip olması gerekiyorsa bu yardımcı olabilir. Tüm ayarlar ana sayfada hala geçersiz kılınabilir.", + "fields.useTitleTemplate.label": "Başlık şablonunu kullan?", + "fields.useTitleTemplate.no": "Hayır - sadece başlık", + "fields.useTitleTemplate.yes": "Evet - şablonla", + "fields.useTitleTemplate.help": "Başlık şablonunun kullanılıp kullanılmayacağını belirtir. Miras alınmayacaktır.", + "writerNodes.template.title": "Sayfa başlığı", + "writerNodes.template.siteTitle": "Site başlığı", + "common.default": "Varsayılan:", + "common.yes": "Evet", + "common.no": "Hayır", + "sitemap.title": "Site Haritası", + "sitemap.index": "Site Haritası Dizini", + "sitemap.description": "Web sitenizdeki dizine eklenebilecek sayfalar hakkında arama motorlarını bilgilendiren web sitenizin site haritasıdır.", + "sitemap.by": "tarafından", + "sitemap.changefreq": "Değişim Sıklığı", + "sitemap.lastUpdated": "Son Güncelleme", + "sitemap.priority": "Öncelik", + "sitemap.url": "URL", + "sitemap.noEntries": "Giriş yok", + "utmShare.button": "Paylaş", + "utmShare.parameters": "Parametreler", + "utmShare.source.label": "Kaynak", + "utmShare.source.placeholder": "örn. google, bülten", + "utmShare.medium.label": "Ortam", + "utmShare.medium.placeholder": "örn. cpc, e-posta, sosyal medya", + "utmShare.campaign.label": "Kampanya", + "utmShare.campaign.placeholder": "örn. bahar_indirimi", + "utmShare.content.label": "İçerik", + "utmShare.content.placeholder": "örn. logo_linki", + "utmShare.term.label": "Terim", + "utmShare.term.placeholder": "örn. koşu ayakkabıları", + "utmShare.ref.label": "Ref", + "utmShare.ref.placeholder": "örn. getkirby.com", + "ai.action.generate": "Yapay zeka ile oluştur", + "ai.action.regenerate": "Yeniden oluştur", + "ai.action.edit": "Düzenle...", + "ai.action.customize": "Yapay zeka oluşturmayı özelleştir...", + "ai.action.stop": "Durdur", + "ai.error.request": "Yapay zeka isteği başarısız oldu. Lütfen tekrar dene.", + "ai.error.disabled": "Yapay zeka özellikleri devre dışı.", + "ai.error.permission": "Yapay zeka özelliklerini kullanma izniniz yok.", + "ai.dialog.instructions.label": "Talimatlar", + "ai.dialog.instructions.placeholder": "Metinde hangi değişiklikleri yapmak istiyorsun?", + "ai.dialog.edit.submit": "Değişiklikleri uygula", + "ai.dialog.custom.label": "Özel talimatlar", + "ai.dialog.custom.placeholder": "Ne tür bir içerik oluşturmak istiyorsun?", + "ai.dialog.custom.submit": "Oluştur", + "sections.searchConsole.title": "Google Search Console", + "sections.searchConsole.noCredentials": "Search Console'u bağlamak için Google Cloud kimlik bilgilerini ayarlayın. Kurulum talimatları için belgelere göz atın.", + "sections.searchConsole.notConnected": "Bu sayfa için arama verilerini görmek üzere Google hesabınızı bağlayın.", + "sections.searchConsole.selectProperty": "Hangi Search Console özelliğinin kullanılacağını seçin.", + "sections.searchConsole.selectPropertyButton": "Özellik seç", + "sections.searchConsole.selectPropertyLabel": "Özellik", + "sections.searchConsole.scDomain": "alan adı", + "sections.searchConsole.docs": "Belgeler", + "sections.searchConsole.connect": "Bağlan", + "sections.searchConsole.reconnect": "Yeniden bağlan", + "sections.searchConsole.noData": "Bu sayfa için kullanılabilir arama verisi yok.", + "sections.searchConsole.showMore": "Tümünü göster", + "sections.searchConsole.sortBy": "Sıralama ölçütü", + "sections.searchConsole.query": "Sorgu", + "sections.searchConsole.clicks": "Tıklamalar", + "sections.searchConsole.impressions": "Gösterimler", + "sections.searchConsole.ctr": "TO", + "sections.searchConsole.position": "Konum", + "sections.searchConsole.openInGsc": "Search Console'da aç" +}