diff --git a/assets/css/custom-panel.css b/assets/css/custom-panel.css index de0b99e..c8cd413 100644 --- a/assets/css/custom-panel.css +++ b/assets/css/custom-panel.css @@ -130,3 +130,11 @@ .k-code-editor-input[data-size="custom-size"] { min-height: 2rem; } + +input[type="checkbox"][data-variant="toggle"]::after { + background-color: #000; +} + +input[type="checkbox"][data-variant="toggle"]:checked::after { + background-color: #fff; +} diff --git a/composer.json b/composer.json index 4f11ac9..6d1634e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,8 @@ "require": { "php": "~8.2.0 || ~8.3.0 || ~8.4.0 || ~8.5.0", "getkirby/cms": "^5.2", - "sylvainjule/code-editor": "^1.1" + "sylvainjule/code-editor": "^1.1", + "tobimori/kirby-seo": "^2.0.0-beta.2" }, "config": { "allow-plugins": { diff --git a/composer.lock b/composer.lock index 2b39fe6..236f17e 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": "07c4d6a85de1d10e6c6fc0e5cec09033", + "content-hash": "f0e4fb17cfdab02969f2b43fc6538f97", "packages": [ { "name": "christian-riesen/base32", @@ -1241,12 +1241,82 @@ } ], "time": "2025-12-04T18:11:45+00:00" + }, + { + "name": "tobimori/kirby-seo", + "version": "2.0.0-beta.3", + "source": { + "type": "git", + "url": "https://github.com/tobimori/kirby-seo.git", + "reference": "c16472022f53eba9c58ec73b10926129f889f86d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tobimori/kirby-seo/zipball/c16472022f53eba9c58ec73b10926129f889f86d", + "reference": "c16472022f53eba9c58ec73b10926129f889f86d", + "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": { + "ext-imagick": "Rasterize non-resizable images (SVG, etc.) for AI alt text generation", + "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-beta.3" + }, + "funding": [ + { + "url": "https://plugins.andkindness.com/seo/preorder", + "type": "custom" + }, + { + "url": "https://github.com/tobimori", + "type": "github" + } + ], + "time": "2026-03-10T23:31:27+00:00" } ], "packages-dev": [], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": { + "tobimori/kirby-seo": 10 + }, "prefer-stable": false, "prefer-lowest": false, "platform": { diff --git a/site/blueprints/pages/about.yml b/site/blueprints/pages/about.yml index 57c9ba9..3da8408 100644 --- a/site/blueprints/pages/about.yml +++ b/site/blueprints/pages/about.yml @@ -79,3 +79,5 @@ tabs: back: "#0e1e43" text: "{{ file.memberName }}" info: "{{ file.role }}" + + seo: seo/page diff --git a/site/blueprints/pages/article.yml b/site/blueprints/pages/article.yml index 2694f5c..f8ed586 100644 --- a/site/blueprints/pages/article.yml +++ b/site/blueprints/pages/article.yml @@ -111,3 +111,5 @@ tabs: query: site.find('blog').children.listed max: 3 help: "Articles similaires à afficher en bas de page" + + seo: seo/page diff --git a/site/blueprints/pages/blog.yml b/site/blueprints/pages/blog.yml index 3b6d8b7..bff0dc3 100644 --- a/site/blueprints/pages/blog.yml +++ b/site/blueprints/pages/blog.yml @@ -54,3 +54,5 @@ tabs: ratio: 16/9 cover: true info: "{{ page.published.toDate('d/m/Y') }}" + + seo: seo/page diff --git a/site/blueprints/pages/default.yml b/site/blueprints/pages/default.yml index aad110c..cb3a7d8 100644 --- a/site/blueprints/pages/default.yml +++ b/site/blueprints/pages/default.yml @@ -1,29 +1,33 @@ title: Default Page -columns: - main: - width: 2/3 - sections: - fields: - type: fields - fields: - text: - type: writer - marks: - - bold - - italic - - green - - pixel - - underline - - strike - - clear - - link - sidebar: - width: 1/3 - sections: - pages: - type: pages - template: default - files: - type: files +tabs: + content: + label: Contenu + columns: + main: + width: 2/3 + sections: + fields: + type: fields + fields: + text: + type: writer + marks: + - bold + - italic + - green + - pixel + - underline + - strike + - clear + - link + sidebar: + width: 1/3 + sections: + pages: + type: pages + template: default + files: + type: files + seo: seo/page diff --git a/site/blueprints/pages/expertise.yml b/site/blueprints/pages/expertise.yml index fb2a781..cad580b 100644 --- a/site/blueprints/pages/expertise.yml +++ b/site/blueprints/pages/expertise.yml @@ -74,3 +74,5 @@ tabs: uploads: template: video width: 1/2 + + seo: seo/page diff --git a/site/blueprints/pages/game.yml b/site/blueprints/pages/game.yml index 618004e..d9d279d 100644 --- a/site/blueprints/pages/game.yml +++ b/site/blueprints/pages/game.yml @@ -12,75 +12,80 @@ status: label: Public text: Le jeu est visible publiquement -columns: - - width: 2/10 - fields: - thumbnail: - label: Vignette - type: files - layout: cards - size: small - max: 1 - accept: image/* - translate: false - image: - ratio: 1/1 - uploads: - template: image - help: Pour le carousel de navigation parmi les jeux - - width: 2/10 - fields: - lettering: - label: Lettrage - type: files - multiple: false - translate: false - layout: cards - size: tiny - uploads: - template: image - help: Affiché au-dessus de la description - width: 1/3 - - width: 3/10 - fields: - description: - label: Description - type: writer - marks: - - bold - - italic - - green - - pixel - - underline - - strike - - clear - - link - maxlength: 200 - playLink: - label: Lien(s) pour jouer - help: Laissez vide pour afficher "à venir / coming soon" - translate: false - type: url - - - width: 3/10 - sections: - previewCol: - type: fields +tabs: + content: + label: Contenu + columns: + - width: 2/10 fields: - backgroundColor: - label: Couleur d'arrière plan - type: code-editor - language: css - size: custom-size - default: radial-gradient(circle at 20% 80%, rgb(240, 154, 110) 0%, rgb(233, 101, 122) 100%) - translate: false - help: À remplir avec la valeur de la propriété CSS `background-color` souhaitée - preview: - label: Aperçu + thumbnail: + label: Vignette type: files layout: cards - multiple: false + size: small + max: 1 + accept: image/* translate: false + image: + ratio: 1/1 uploads: template: image - help: Image affichée à droite de la description (sur ordinateur uniquement) + help: Pour le carousel de navigation parmi les jeux + - width: 2/10 + fields: + lettering: + label: Lettrage + type: files + multiple: false + translate: false + layout: cards + size: tiny + uploads: + template: image + help: Affiché au-dessus de la description + width: 1/3 + - width: 3/10 + fields: + description: + label: Description + type: writer + marks: + - bold + - italic + - green + - pixel + - underline + - strike + - clear + - link + maxlength: 200 + playLink: + label: Lien(s) pour jouer + help: Laissez vide pour afficher "à venir / coming soon" + translate: false + type: url + + - width: 3/10 + sections: + previewCol: + type: fields + fields: + backgroundColor: + label: Couleur d'arrière plan + type: code-editor + language: css + size: custom-size + default: radial-gradient(circle at 20% 80%, rgb(240, 154, 110) 0%, rgb(233, 101, 122) 100%) + translate: false + help: À remplir avec la valeur de la propriété CSS `background-color` souhaitée + preview: + label: Aperçu + type: files + layout: cards + multiple: false + translate: false + uploads: + template: image + help: Image affichée à droite de la description (sur ordinateur uniquement) + + seo: seo/page diff --git a/site/blueprints/pages/home.yml b/site/blueprints/pages/home.yml index 0068d42..9b1aaad 100644 --- a/site/blueprints/pages/home.yml +++ b/site/blueprints/pages/home.yml @@ -85,3 +85,5 @@ tabs: cover: true help: Image affichée au besoin pendant le chargement de la vidéo width: 1/2 + + seo: seo/page diff --git a/site/blueprints/pages/play.yml b/site/blueprints/pages/play.yml index 77132f3..3a74fca 100644 --- a/site/blueprints/pages/play.yml +++ b/site/blueprints/pages/play.yml @@ -24,3 +24,5 @@ tabs: template: game info: "{{ page.statusLabel }}" create: game + + seo: seo/page diff --git a/site/blueprints/pages/portfolio.yml b/site/blueprints/pages/portfolio.yml index e9d1434..f57ab03 100644 --- a/site/blueprints/pages/portfolio.yml +++ b/site/blueprints/pages/portfolio.yml @@ -44,3 +44,5 @@ tabs: template: project info: "{{ page.catchPhrase }}" create: project + + seo: seo/page diff --git a/site/blueprints/pages/project.yml b/site/blueprints/pages/project.yml index 5945db1..a060a6e 100644 --- a/site/blueprints/pages/project.yml +++ b/site/blueprints/pages/project.yml @@ -12,150 +12,155 @@ icon: image # label: Publié # text: Le projet est visible publiquement -columns: - # Colonne principale - main: - width: 2/3 - sections: - # Informations principales - info: - type: fields - fields: - catchPhrase: - label: Phrase d'accroche - type: writer - nodes: false - marks: - - bold - - italic - - green - - pixel - - underline - - strike - - clear - - link - help: "Ex: Transformez votre lecture en aventure." - description: - label: Description - type: writer - marks: - - bold - - italic - - green - - pixel - - underline - - strike - - clear - - link - maxlength: 500 - help: Description complète du projet - - images: - type: fields - fields: - imagesGallery: - width: 2/3 - label: Galerie d'images - type: files - layout: cards - size: small - min: 6 - accept: image/* - translate: false - image: - back: #ffffff - uploads: - template: image - help: "Une animation sera générée à partir des images de ce champ. Minimum optimal d'images : 6" - mockup: - width: 1/3 - label: Image de mise en situation - type: files - layout: cards - max: 1 - size: small - accept: image/* - translate: false - image: - ratio: 1/1 - back: #ffffff - uploads: - template: image - help: Écran de jeu mis en situation sur un appareil - - # Sidebar - sidebar: - width: 1/3 - sections: - meta: - type: fields - fields: - thumbnail: - label: Vignette - type: files - required: true - layout: cards - size: small - max: 1 - accept: image/* - translate: false - image: - ratio: 1/1 - uploads: - template: image - help: Petite image carrée représentant le jeu - galleryAnimationMode: - label: Mode d'animation de la galerie - type: toggles - default: vertical - options: - - value: vertical - text: Vertical - icon: arrow-up-down - - value: horizontal - text: Horizontal - icon: arrow-left-right - help: "Direction du défilement des images dans la galerie animée" - galleryBackgroundColor: - label: Couleur d'arrière-plan de la galerie animée - type: color - alpha: false - galleryBackgroundImage: - label: Image d'arrière-plan - type: files - multiple: false - keywords: - label: Mots clés - type: structure +tabs: + content: + label: Contenu + columns: + # Colonne principale + main: + width: 2/3 + sections: + # Informations principales + info: + type: fields fields: - label: - label: Label - required: true - type: text - width: 1/2 - placeholder: "Ex: Impact, Catégorie..." - text: - label: Texte - required: true - type: text - width: 1/2 + catchPhrase: + label: Phrase d'accroche + type: writer + nodes: false + marks: + - bold + - italic + - green + - pixel + - underline + - strike + - clear + - link + help: "Ex: Transformez votre lecture en aventure." + description: + label: Description + type: writer + marks: + - bold + - italic + - green + - pixel + - underline + - strike + - clear + - link + maxlength: 500 + help: Description complète du projet - # Liens externes - links: - type: fields - fields: - externalLinks: - label: Liens externes - type: structure + images: + type: fields fields: - label: - label: Nom du bouton + imagesGallery: + width: 2/3 + label: Galerie d'images + type: files + layout: cards + size: small + min: 6 + accept: image/* + translate: false + image: + back: #ffffff + uploads: + template: image + help: "Une animation sera générée à partir des images de ce champ. Minimum optimal d'images : 6" + mockup: + width: 1/3 + label: Image de mise en situation + type: files + layout: cards + max: 1 + size: small + accept: image/* + translate: false + image: + ratio: 1/1 + back: #ffffff + uploads: + template: image + help: Écran de jeu mis en situation sur un appareil + + # Sidebar + sidebar: + width: 1/3 + sections: + meta: + type: fields + fields: + thumbnail: + label: Vignette + type: files required: true - type: text - width: 1/2 - placeholder: "Ex: App Store, Site web..." - url: - label: URL - required: true - type: url - width: 1/2 + layout: cards + size: small + max: 1 + accept: image/* + translate: false + image: + ratio: 1/1 + uploads: + template: image + help: Petite image carrée représentant le jeu + galleryAnimationMode: + label: Mode d'animation de la galerie + type: toggles + default: vertical + options: + - value: vertical + text: Vertical + icon: arrow-up-down + - value: horizontal + text: Horizontal + icon: arrow-left-right + help: "Direction du défilement des images dans la galerie animée" + galleryBackgroundColor: + label: Couleur d'arrière-plan de la galerie animée + type: color + alpha: false + galleryBackgroundImage: + label: Image d'arrière-plan + type: files + multiple: false + keywords: + label: Mots clés + type: structure + fields: + label: + label: Label + required: true + type: text + width: 1/2 + placeholder: "Ex: Impact, Catégorie..." + text: + label: Texte + required: true + type: text + width: 1/2 + + # Liens externes + links: + type: fields + fields: + externalLinks: + label: Liens externes + type: structure + fields: + label: + label: Nom du bouton + required: true + type: text + width: 1/2 + placeholder: "Ex: App Store, Site web..." + url: + label: URL + required: true + type: url + width: 1/2 + + seo: seo/page diff --git a/site/blueprints/pages/white-paper.yml b/site/blueprints/pages/white-paper.yml index c97619b..f2cd21a 100644 --- a/site/blueprints/pages/white-paper.yml +++ b/site/blueprints/pages/white-paper.yml @@ -59,3 +59,5 @@ tabs: accept: application/pdf translate: false help: Fichier téléchargé après soumission du formulaire + + seo: seo/page diff --git a/site/blueprints/pages/white-papers.yml b/site/blueprints/pages/white-papers.yml index b14fd3b..90e374a 100644 --- a/site/blueprints/pages/white-papers.yml +++ b/site/blueprints/pages/white-papers.yml @@ -88,3 +88,5 @@ tabs: downloadedAt: type: text label: Date + + seo: seo/page diff --git a/site/blueprints/site.yml b/site/blueprints/site.yml index 45b03ad..522b86a 100644 --- a/site/blueprints/site.yml +++ b/site/blueprints/site.yml @@ -1,6 +1,7 @@ title: World Game tabs: + seo: seo/site mainTab: label: Principal columns: diff --git a/site/config/config.php b/site/config/config.php index 40b0846..8d08dca 100644 --- a/site/config/config.php +++ b/site/config/config.php @@ -15,4 +15,16 @@ return [ 'routes' => [ require(__DIR__ . '/routes/download-white-paper.php') ], + + 'tobimori.seo' => [ + // TODO: définir l'URL de production pour éviter le duplicate content + // 'canonicalBase' => 'https://www.worldgame.fr', + 'sitemap' => [ + 'excludeTemplates' => ['error'], + 'changefreq' => 'weekly', + ], + 'robots' => [ + 'active' => true, + ], + ], ]; 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..ac3574e --- /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 Beta version of the plugin: + +`composer require tobimori/kirby-seo:^2.0.0-beta.2` + +### What does Beta 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..9448920 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai.php @@ -0,0 +1,65 @@ +text($prompt)]; + + return self::provider()->stream($content); + } +} 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/Content.php b/site/plugins/kirby-seo/classes/Ai/Content.php new file mode 100644 index 0000000..fe6ce1b --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Content.php @@ -0,0 +1,86 @@ +role = $role; + } + + public static function user(): static + { + return new static('user'); + } + + public static function assistant(): static + { + return new static('assistant'); + } + + public static function system(): static + { + return new static('system'); + } + + public function text(string $text): static + { + $this->blocks[] = ['type' => 'text', 'text' => $text]; + return $this; + } + + /** + * Adds an image block from a Kirby File, converted to WebP for smaller payloads. + * Non-resizable formats (SVG, etc.) are rasterized via Imagick. + */ + public function image(File $file, int $maxDimension = 1024): static + { + if ($file->isResizable()) { + $thumb = $file->thumb([ + 'width' => $maxDimension, + 'height' => $maxDimension, + 'format' => 'webp', + ]); + + $data = base64_encode($thumb->read()); + } else { + // TODO: better handling without ext-imagick + $imagick = new Imagick(); + $imagick->readImage($file->root()); + $imagick->setImageFormat('webp'); + $imagick->thumbnailImage($maxDimension, $maxDimension, true); + $data = base64_encode($imagick->getImageBlob()); + $imagick->clear(); + $imagick->destroy(); + } + + $this->blocks[] = [ + 'type' => 'image', + 'data' => $data, + 'mediaType' => 'image/webp', + ]; + + return $this; + } + + public function role(): string + { + return $this->role; + } + + public function blocks(): array + { + return $this->blocks; + } +} 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..eeaf46d --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Driver.php @@ -0,0 +1,40 @@ + $content Array of Content messages forming a conversation. + * @param string|null $model Model override. + * + * @return Generator + */ + abstract public function stream(array $content, 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..5075c56 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Drivers/Anthropic.php @@ -0,0 +1,140 @@ +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' => $this->buildMessages($content), + '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; + } + }); + } + + /** + * Translates an array of Content messages into the Anthropic messages format. + * + * @param array $content + */ + private function buildMessages(array $content): array + { + $messages = []; + + foreach ($content as $message) { + $blocks = []; + foreach ($message->blocks() as $block) { + if ($block['type'] === 'image') { + $blocks[] = [ + 'type' => 'image', + 'source' => [ + 'type' => 'base64', + 'media_type' => $block['mediaType'], + 'data' => $block['data'], + ], + ]; + } elseif ($block['type'] === 'text') { + $blocks[] = [ + 'type' => 'text', + 'text' => $block['text'], + ]; + } + } + + $messages[] = [ + 'role' => $message->role(), + 'content' => $blocks, + ]; + } + + return $messages; + } +} diff --git a/site/plugins/kirby-seo/classes/Ai/Drivers/Gemini.php b/site/plugins/kirby-seo/classes/Ai/Drivers/Gemini.php new file mode 100644 index 0000000..cb508a1 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Drivers/Gemini.php @@ -0,0 +1,149 @@ +config('apiKey', required: true); + $model = $model ?? $this->config('model', static::DEFAULT_MODEL); + $baseEndpoint = $this->config('endpoint', static::DEFAULT_ENDPOINT); + $endpoint = "{$baseEndpoint}/models/{$model}:streamGenerateContent?alt=sse&key={$apiKey}"; + + $headers = [ + 'Content-Type: application/json', + ]; + + $payload = [ + 'contents' => $this->buildContents($content), + ]; + + $systemInstruction = $this->buildSystemInstruction($content); + if ($systemInstruction !== null) { + $payload['systemInstruction'] = $systemInstruction; + } + + $stream = new SseStream($endpoint, $headers, $payload, (int)$this->config('timeout', 120)); + $started = false; + + yield from $stream->stream(function (array $event) use (&$started): Generator { + $candidates = $event['candidates'] ?? []; + $candidate = $candidates[0] ?? null; + + if ($candidate === null) { + $error = $event['error'] ?? null; + if ($error) { + yield Chunk::error($error['message'] ?? 'Unknown Gemini error.', $event); + } + return; + } + + if (!$started) { + yield Chunk::streamStart($event); + yield Chunk::textStart($event); + $started = true; + } + + $finishReason = $candidate['finishReason'] ?? null; + if ($finishReason === 'SAFETY') { + yield Chunk::error('Response blocked by safety filters.', $event); + return; + } + + $parts = $candidate['content']['parts'] ?? []; + foreach ($parts as $part) { + $text = $part['text'] ?? ''; + if ($text !== '') { + yield Chunk::textDelta($text, $event); + } + } + + if ($finishReason !== null) { + yield Chunk::textComplete($event); + yield Chunk::streamEnd($event); + } + }); + } + + /** + * Translates an array of Content messages into the Gemini contents format. + * + * @param array $content + */ + private function buildContents(array $content): array + { + $contents = []; + + foreach ($content as $message) { + if ($message->role() === 'system') { + continue; + } + + $parts = []; + foreach ($message->blocks() as $block) { + if ($block['type'] === 'image') { + $parts[] = [ + 'inline_data' => [ + 'mime_type' => $block['mediaType'], + 'data' => $block['data'], + ], + ]; + } elseif ($block['type'] === 'text') { + $parts[] = [ + 'text' => $block['text'], + ]; + } + } + + $contents[] = [ + 'role' => $message->role() === 'assistant' ? 'model' : 'user', + 'parts' => $parts, + ]; + } + + return $contents; + } + + /** + * Extracts system messages into a Gemini systemInstruction object. + * + * @param array $content + */ + private function buildSystemInstruction(array $content): array|null + { + $parts = []; + + foreach ($content as $message) { + if ($message->role() !== 'system') { + continue; + } + + foreach ($message->blocks() as $block) { + if ($block['type'] === 'text') { + $parts[] = ['text' => $block['text']]; + } + } + } + + if ($parts === []) { + return null; + } + + return ['parts' => $parts]; + } +} 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..a5c69d3 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/Drivers/OpenAi.php @@ -0,0 +1,118 @@ +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' => $this->buildInput($content), + // 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); + } + }); + } + + /** + * Translates an array of Content messages into the OpenAI Responses API input format. + * + * @param array $content + */ + private function buildInput(array $content): array + { + $input = []; + + foreach ($content as $message) { + $blocks = []; + + foreach ($message->blocks() as $block) { + if ($block['type'] === 'image') { + $blocks[] = [ + 'type' => 'input_image', + 'image_url' => "data:{$block['mediaType']};base64,{$block['data']}", + ]; + } elseif ($block['type'] === 'text') { + $blocks[] = [ + 'type' => 'input_text', + 'text' => $block['text'], + ]; + } + } + + $input[] = [ + 'role' => $message->role(), + 'content' => $blocks, + ]; + } + + return $input; + } +} 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..a746b5f --- /dev/null +++ b/site/plugins/kirby-seo/classes/Ai/SseStream.php @@ -0,0 +1,194 @@ + $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); + } + } + + /** + * @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/AltText.php b/site/plugins/kirby-seo/classes/AltText.php new file mode 100644 index 0000000..65c8e16 --- /dev/null +++ b/site/plugins/kirby-seo/classes/AltText.php @@ -0,0 +1,126 @@ +value()); + } + + public function text(): string + { + return $this->text; + } + + public function isDecorative(): bool + { + return $this->decorative; + } + + public function source(): string + { + return $this->source; + } + + public function isMissing(): bool + { + return !$this->decorative && trim($this->text) === ''; + } + + public function isAiGenerated(): bool + { + return $this->source === self::SOURCE_AI; + } + + public function isReviewed(): bool + { + return $this->source === self::SOURCE_REVIEWED; + } + + public function toArray(): array + { + return [ + 'text' => $this->text, + 'decorative' => $this->decorative, + 'source' => $this->source, + ]; + } + + /** + * Returns HTML attributes for the alt text. + */ + public function toAttr(): array + { + return ['alt' => $this->decorative ? '' : $this->text]; + } + + public function toYaml(): string + { + return Yaml::encode($this->toArray()); + } + + /** + * Returns the resolved alt text as a Kirby Field for chaining (.or(), .isNotEmpty(), etc.) + */ + public function toField(): Field + { + return new Field(null, 'alt', (string)$this); + } + + public function __toString(): string + { + if ($this->decorative) { + return ''; + } + + return $this->text; + } +} 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..c42390a --- /dev/null +++ b/site/plugins/kirby-seo/classes/Buttons/RobotsViewButton.php @@ -0,0 +1,41 @@ +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/Field/AltTextField.php b/site/plugins/kirby-seo/classes/Field/AltTextField.php new file mode 100644 index 0000000..41462e8 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Field/AltTextField.php @@ -0,0 +1,316 @@ +autogenerate = $params['autogenerate'] ?? false; + parent::__construct($params); + $this->setAi($params['ai'] ?? true); + } + + public function type(): string + { + return 'alt-text'; + } + + protected function setAi(bool $ai = true): void + { + if ($ai && !Seo::option('components.ai')::enabled()) { + $ai = false; + } + + if ($ai && App::instance()->user()?->role()->permissions()->for('tobimori.seo', 'ai') === false) { + $ai = false; + } + + $this->ai = $ai; + } + + public function ai(): bool + { + return $this->ai; + } + + public function autogenerate(): bool + { + return $this->autogenerate; + } + + public function fill(mixed $value): static + { + if (is_array($value)) { + $this->value = $value; + } else { + $this->value = AltText::parse($value)->toArray(); + } + + return $this; + } + + public function toFormValue(): mixed + { + return $this->value; + } + + public function toStoredValue(): mixed + { + if (is_array($this->value)) { + $altText = new AltText( + text: $this->value['text'] ?? '', + decorative: $this->value['decorative'] ?? false, + source: $this->value['source'] ?? AltText::SOURCE_MANUAL, + ); + + if ($altText->isMissing()) { + return ''; + } + + return $altText->toYaml(); + } + + return $this->value; + } + + public function props(): array + { + return [ + ...parent::props(), + 'ai' => $this->ai(), + 'autogenerate' => $this->autogenerate(), + ]; + } + + public function routes(): array + { + $field = $this; + + return [ + [ + 'pattern' => 'ai/stream', + 'method' => 'POST', + 'action' => function () use ($field) { + $kirby = App::instance(); + $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); + } + + $model = $field->model(); + + if (!$model instanceof File || $model->type() !== 'image') { + return Response::json([ + 'status' => 'error', + 'message' => 'Field must be on an image file.' + ], 400); + } + + $data = $kirby->request()->body()->data(); + $lang = $kirby->api()->language(); + + if ($lang) { + $kirby->setCurrentLanguage($lang); + } + + // begin SSE stream + 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 { + $kirby->data = [ + 'file' => $model, + 'site' => $kirby->site(), + 'kirby' => $kirby, + ]; + + $prompt = trim(snippet('seo/prompts/tasks/alt-text', [ + 'file' => $model, + 'instructions' => $data['instructions'] ?? null, + ], return: true)); + + $content = [ + Content::user() + ->image($model) + ->text($prompt), + ]; + + foreach ($component::provider()->stream($content) as $chunk) { + $send([ + 'type' => $chunk->type, + 'text' => $chunk->text, + 'payload' => $chunk->payload, + ]); + } + } catch (\Throwable $exception) { + $send([ + 'type' => 'error', + 'payload' => [ + 'message' => $exception->getMessage(), + ], + ]); + } + + exit(); + } + ] + ]; + } + + /** + * Generates alt text for all autogenerate-enabled fields on a file. + * Handles both single-lang and multi-lang sites in a single AI call. + */ + public static function generateForFile(File $file): File + { + if ($file->type() !== 'image') { + return $file; + } + + $component = Seo::option('components.ai'); + if (!$component::enabled()) { + return $file; + } + + $blueprint = $file->blueprint(); + $autogenerateFields = []; + + foreach ($blueprint->fields() as $name => $field) { + $fieldClass = Field::$types[$field['type'] ?? ''] ?? null; + if (!is_a($fieldClass, static::class, true)) { + continue; + } + + if (empty($field['autogenerate'])) { + continue; + } + + $autogenerateFields[] = $name; + } + + if ($autogenerateFields === []) { + return $file; + } + + $kirby = $file->kirby(); + $languages = $kirby->languages(); + $isMultiLang = $languages->isNotEmpty(); + + $kirby->data = [ + 'file' => $file, + 'site' => $kirby->site(), + 'kirby' => $kirby, + ]; + + $langCodes = $isMultiLang + ? $languages->pluck('code') + : []; + + $prompt = trim(snippet('seo/prompts/tasks/alt-text', [ + 'file' => $file, + 'languages' => $langCodes, + ], return: true)); + + $content = [ + Content::user() + ->image($file) + ->text($prompt), + ]; + + $text = ''; + foreach ($component::provider()->stream($content) as $chunk) { + if ($chunk->type === 'text-delta') { + $text .= $chunk->text; + } + } + + $text = trim($text); + if ($text === '') { + return $file; + } + + // parse into [langCode => altText] map (single-lang uses null key) + $results = []; + + if ($isMultiLang) { + foreach (explode("\n", $text) as $line) { + $line = trim($line); + if ($line === '' || !str_contains($line, ':')) { + continue; + } + + $colonPos = strpos($line, ':'); + $code = trim(substr($line, 0, $colonPos)); + $value = trim(substr($line, $colonPos + 1)); + + if ($value !== '' && in_array($code, $langCodes, true)) { + $results[$code] = $value; + } + } + } else { + $results[null] = $text; + } + + return $kirby->impersonate('kirby', function () use ($file, $results, $autogenerateFields) { + foreach ($results as $langCode => $altText) { + $updates = []; + foreach ($autogenerateFields as $name) { + $updates[$name] = (new AltText(text: $altText, source: AltText::SOURCE_AI))->toYaml(); + } + + $file = $file->update($updates, $langCode); + } + + return $file; + }); + } +} 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/Jobs/GenerateAltTextJob.php b/site/plugins/kirby-seo/classes/Jobs/GenerateAltTextJob.php new file mode 100644 index 0000000..6a7696f --- /dev/null +++ b/site/plugins/kirby-seo/classes/Jobs/GenerateAltTextJob.php @@ -0,0 +1,35 @@ +payload()['fileId']; + $file = App::instance()->file($fileId); + + if ($file === null) { + throw new \Exception("File not found: {$fileId}"); + } + + AltTextField::generateForFile($file); + } +} diff --git a/site/plugins/kirby-seo/classes/Meta.php b/site/plugins/kirby-seo/classes/Meta.php new file mode 100644 index 0000000..1e9d093 --- /dev/null +++ b/site/plugins/kirby-seo/classes/Meta.php @@ -0,0 +1,762 @@ +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:.+/' + ] + ] + ]; + + /** + * Decode HTML entities from a value to prevent double-encoding + * when the value is later passed through Html::tag() which applies htmlspecialchars(). + * This is necessary because Writer fields store content as HTML (e.g. & as &). + */ + protected static function decodeEntities(mixed $value): mixed + { + if (is_a($value, Field::class)) { + return new Field($value->model(), $value->key(), html_entity_decode($value->value(), ENT_QUOTES | ENT_HTML5, 'UTF-8')); + } + + if (is_string($value)) { + return html_entity_decode($value, ENT_QUOTES | ENT_HTML5, 'UTF-8'); + } + + return $value; + } + + /** + * 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, and decode entities + array_walk($value, function (&$item) { + if (is_callable($item)) { + $item = $item($this->page); + } + $item = self::decodeEntities($item); + }); + + // add the tag to the array + $tags[] = [ + 'tag' => $tag['tag'], + 'attributes' => $value, + 'content' => null, + 'priority' => $tag['priority'] ?? false, + ]; + continue; + } + + // Decode HTML entities to prevent double-encoding by Html::tag() + $value = self::decodeEntities($value); + + // 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 = [ + 'ogDescription' => 'metaDescription', + ]; + + /** + * 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', + ]; + + /** + * 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..827885e --- /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 = App::instance()->url() . '/sitemap.xsl'; + $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..da3b4ce --- /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 = App::instance()->url() . '/sitemap.xsl'; + $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..c12ff04 --- /dev/null +++ b/site/plugins/kirby-seo/composer.json @@ -0,0 +1,50 @@ +{ + "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-beta.3", + "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": { + "ext-imagick": "Rasterize non-resizable images (SVG, etc.) for AI alt text generation", + "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..b137910 --- /dev/null +++ b/site/plugins/kirby-seo/config/areas.php @@ -0,0 +1,145 @@ + fn () => + [ + 'buttons' => [ + 'page.robots' => fn (Page $page) => Seo::option('robots.enabled') ? new RobotsViewButton($page) : null, + '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..e2a50b4 --- /dev/null +++ b/site/plugins/kirby-seo/config/fields.php @@ -0,0 +1,152 @@ + [ + 'extends' => 'writer', + 'computed' => [ + 'placeholder' => function () { + if ($this->placeholder === null) { + return null; + } + + $value = $this->model()->toString($this->placeholder); + + if (Str::contains($value, 'data-seo-template-variable')) { + $value = Str::unhtml($value); + } + + return str_replace( + ['{{ title }}', '{{ site.title }}'], + [t('seo.writerNodes.template.title'), t('seo.writerNodes.template.siteTitle')], + $value + ); + } + ], + '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(); + } + ] + ] + ], + 'alt-text' => AltTextField::class, +]; diff --git a/site/plugins/kirby-seo/config/hooks.php b/site/plugins/kirby-seo/config/hooks.php new file mode 100644 index 0000000..771475f --- /dev/null +++ b/site/plugins/kirby-seo/config/hooks.php @@ -0,0 +1,86 @@ + function () { + if (class_exists('tobimori\Queues\Queues')) { + \tobimori\Queues\Queues::register(\tobimori\Seo\Jobs\GenerateAltTextJob::class); + } + }, + 'file.create:after' => function (File $file) { + if ($file->type() !== 'image') { + return; + } + + if (class_exists('tobimori\Queues\Queues')) { + \tobimori\Queues\Queues::push('seo:generate-alt-text', [ + 'fileId' => $file->id(), + ]); + + return $file; + } + + return AltTextField::generateForFile($file); + }, + 'page.update:after' => function (Page $newPage, Page $oldPage) { + // only inject blueprint defaults if the seo tab is present + if ($newPage->blueprint()->tab('seo')) { + $updates = A::reduce( + $newPage->kirby()->option('tobimori.seo.robots.types'), + function ($carry, $robots) use ($newPage) { + $upper = Str::ucfirst($robots); + + if ($newPage->content()->get("robots{$upper}")->value() === '') { + $carry["robots{$upper}"] = 'default'; + } + + return $carry; + }, + [] + ); + + if (A::count($updates)) { + $newPage = $newPage->update($updates, $newPage->kirby()->languageCode()); + } + } + + if (Seo::option('indexnow.enabled')) { + $indexNow = new (Seo::option('components.indexnow'))($newPage); + $indexNow->request(); + } + + return $newPage; + }, + 'page.changeStatus:after' => function (Page $newPage, Page $oldPage) { + if (Seo::option('indexnow.enabled')) { + $indexNow = new (Seo::option('components.indexnow'))($newPage); + $indexNow->request(); + } + }, + 'page.changeSlug:after' => function (Page $newPage, Page $oldPage) { + if (Seo::option('indexnow.enabled')) { + $indexNow = new (Seo::option('components.indexnow'))($newPage); + $indexNow->request(); + } + }, + 'page.render:before' => function (string $contentType, array $data, Page $page) { + if (!class_exists('Spatie\SchemaOrg\Schema')) { + return; + } + + if (option('tobimori.seo.generateSchema')) { + $page->schema('WebSite') + ->url($page->metadata()->canonicalUrl()) + ->copyrightYear(date('Y')) + ->description($page->metadata()->metaDescription()) + ->name($page->metadata()->metaTitle()) + ->headline($page->metadata()->title()); + } + }, +]; diff --git a/site/plugins/kirby-seo/config/options.php b/site/plugins/kirby-seo/config/options.php new file mode 100644 index 0000000..017989a --- /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', + 'parent', + 'fallbackFields', + '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..7765dda --- /dev/null +++ b/site/plugins/kirby-seo/config/options/ai.php @@ -0,0 +1,39 @@ + true, + 'provider' => 'openai', + 'providers' => [ + 'openai' => [ + 'driver' => OpenAi::class, + 'config' => [ + 'apiKey' => '', // needs to be defined + ], + ], + 'anthropic' => [ + 'driver' => Anthropic::class, + 'config' => [ + 'apiKey' => '', // needs to be defined + ], + ], + 'gemini' => [ + 'driver' => Gemini::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..a97f18b --- /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('seo.sitemap.title'), + ], + ])->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('seo.sitemap.title'), + '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('seo.sitemap.title'), + '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/docs/0_getting-started/0_quickstart.md b/site/plugins/kirby-seo/docs/0_getting-started/0_quickstart.md new file mode 100644 index 0000000..0da2480 --- /dev/null +++ b/site/plugins/kirby-seo/docs/0_getting-started/0_quickstart.md @@ -0,0 +1,141 @@ +--- +title: Quickstart +intro: "All you need to get started with Kirby SEO: Installation & initial configuration" +--- + +## Requirements + +Kirby SEO requires + +- Kirby 5 or later +- PHP 8.3, 8.4 or 8.5 + +Composer is required for full feature support (e.g. schema.org support, background queuing). [Composer](https://getcomposer.org/) is a dependency manager for PHP. If you have never used Composer before, follow the instruction on the [Composer website](https://getcomposer.org/doc/00-intro.md). + +## Installing Kirby SEO + +In a terminal window, navigate to the folder of your Kirby installation. Then run the following command: + +```bash +composer require tobimori/kirby-seo +``` + +Some features require additional packages. Install them when you need them: + +- [Schema.org](2_customization/08_schema-org) requires `spatie/schema-org` +- Background Processing (coming soon) + +
+Manual Installation + +If you prefer not to use Composer, you can manually install Kirby SEO. Go to the [GitHub releases page](https://github.com/tobimori/kirby-seo/releases) and find the latest release. Click on "Assets" to expand it and select "Source code (zip)". Extract the contents of the zip file into the `site/plugins/kirby-seo` folder of your Kirby installation. + +
+ +## Add meta tags to your site + +Kirby SEO needs two snippets in your HTML: one in the `` for meta tags, and one before `` for structured data. + +Find the place in your code where you output the `` tag, this is usually a shared snippet like `header.php` or a layout file. Add the `seo/head` snippet to your `` and the `seo/schemas` snippet before the `` closing tag: + +```php + + + + + + [...] + + + +``` + +Make sure your `` tag also includes the `lang` attribute as shown above. Browsers use it for automatic hyphenation, and Google uses it to determine the language of your page. + +Now open your site in a browser and view the page source. You should already see ``, `<meta>` and Open Graph tags in your `<head>`. The plugin fills them with sensible defaults out of the box. + +## Editing meta tags in the panel + +Next, you want to give your editors control over the SEO fields. Add the SEO tab to your site blueprint: + +```yaml +# site/blueprints/site.yml +tabs: + content: + fields: + # move your existing fields here + seo: seo # <--- add this +``` + +This gives you global defaults for meta titles, descriptions and social images. Any page without its own SEO settings will use these. +Learn more about how defaults work in [Your first Meta Tags](0_getting-started/1_your-first-meta-tags). + +And now add the SEO tab to any page blueprint where editors should be able to override the defaults: + +```yaml +# site/blueprints/pages/default.yml +tabs: + content: + fields: + # move your existing fields here + seo: seo # <--- add this +``` + +Open the Panel and navigate to any page. You'll see a new SEO tab with fields for meta title, description, social images and more. + +Try it: enter a custom meta title, save, and reload the page in your browser. View the source, your title is there. + +Now delete the title you just entered and reload again. The plugin falls back to your page's regular title. + +This is the **Meta Cascade**, the plugin always finds the best available value, so you only need to fill in fields when you want to override the default. [Learn more about the Meta Cascade](0_getting-started/1_your-first-meta-tags). + +## Set your canonical URL + +To prevent duplicate content issues (e.g. if your site is reachable with and without `www`), tell the plugin which URL is the canonical one: + +```php +// site/config/config.php +return [ + // [...] + 'tobimori.seo' => [ + 'canonical' => [ + 'base' => 'https://www.example.com', + ], + ] +]; +``` + +Reload your page and check the source. You'll see a `<link rel="canonical">` tag pointing to your configured domain. + +## Single-language setup + +If you're not using Kirby's [multi-language feature](https://getkirby.com/docs/guide/languages), set your language code so the plugin can generate the correct `og:locale` tag: + +```php +// site/config/config.php +return [ + // [...] + 'tobimori.seo' => [ + 'canonical' => [ + 'base' => 'https://www.example.com', + ], + 'locale' => 'en_US', + ], +]; +``` + +If you already added the canonical config above, add `lang` to the same `tobimori.seo` block. + +If you already have multi-language set up in Kirby the plugin will pick up the language automatically. + +## Purchase license & activate your installation + +Once you publish your website, you need to purchase a Kirby SEO license. We will send you a unique license code for your domain. You can activate your license with the following steps: + +1. Open the Panel at `https://example.com/panel` and log in. +2. Click on the "Metadata & SEO" tab, and click on "Activate" in the top right. +3. Enter your license code and your email address and press "Activate". + +It is not required to activate your license locally. + +## Where to go from here diff --git a/site/plugins/kirby-seo/docs/0_getting-started/1_your-first-meta-tags.md b/site/plugins/kirby-seo/docs/0_getting-started/1_your-first-meta-tags.md new file mode 100644 index 0000000..925639a --- /dev/null +++ b/site/plugins/kirby-seo/docs/0_getting-started/1_your-first-meta-tags.md @@ -0,0 +1,81 @@ +--- +title: Your First Meta Tags +intro: Learn how Kirby SEO decides which meta data to show and how to control it at every level +--- + +In the Quickstart, you installed Kirby SEO and saw meta tags appear in your source code. Now let's look at how to control what shows up, and where. + +## Start with a site-wide default + +Open the Panel, and click on "Metadata & SEO". You'll see something like this: + +![Site SEO tab with meta description field](global-seo-settings.png) + +Quite empty, but these are your global defaults. Every page that doesn't have its own meta data will use what you set here. + +### Meta title templates + +You probably don't want to write a custom meta title for every page. Kirby SEO lets you define a **title template** at the site level. + +Go to the Site SEO tab and find the title template field. Click the buttons to insert placeholders like **Page Title** or **Site Title**, and type any separator you want between them. + +A template like `Page Title | Site Title` turns a page called "About" on a site called "My Blog" into: + +``` +About | My Blog +``` + +Every page that doesn't have a custom meta title will use this pattern automatically. + +### Set a default description + +Below that, you'll find the Page Description field. Enter a default description like "A blog about good food." and save. + +Open any page on your site and view the source. Every page shows this description, because no page has its own yet. + +### Override on a single page + +Navigate to a specific page in the Panel, and open its Metadata & SEO tab. You'll find a slightly different interface than the site tab: + +![Page SEO tab with meta description field](page-seo-settings.png) + +Enter a different description. Save and reload that page in the browser. + +That page now shows its own description. Every other page still shows "A blog about good food." + +### Remove the override + +Delete the description you just entered on the page and save. Reload — the page falls back to the site-wide default again. + +What you just experienced is the **Meta Cascade**. Kirby SEO looks for values in multiple places and uses the most specific one it finds: + +1. **Page fields**: the Metadata & SEO tab on a specific page +2. **Programmatic content**: values set in a Page Model via `metaDefaults()` +3. **Parent page**: inherited from the parent page (if enabled) +4. **Fallback fields**: Open Graph tags fall back to their Meta counterparts +5. **Site globals**: the Metadata & SEO tab on the Site +6. **Plugin defaults** + +The idea is simple: you set sensible defaults once at the site level, and only override where you need something different. Most pages will never need more than a description in their Metadata & SEO tab. + +## Inheriting settings + +So far you've seen two levels: site defaults and page overrides. But what if you have a section of your site — like a blog — where all pages should share specific settings that are different from the rest of your site? + +Open a page's Metadata & SEO tab and use the Inherit settings field. Select which settings should be passed down to its child pages: title templates, descriptions, Open Graph, robots directives, or all at once. Child pages can still override anything individually. + +![Inherit settings field](page-seo-inherit.png) + +## Open Graph & Social + +When someone shares a link to your site on Facebook, Mastodon, Slack or WhatsApp, these platforms look for Open Graph tags in your HTML to build a preview card. The [Open Graph Protocol](https://ogp.me/) is a standard originally created by Facebook that defines how a page's title, description and image appear when shared. + +Kirby SEO generates these tags automatically. The SEO tab has separate fields for Open Graph titles, descriptions and images, but you usually don't need to fill them in. If you don't set an OG title, the plugin uses your meta title. If you don't set an OG image, it uses the default from your site settings. + +Set a default OG image in the Site SEO tab so every shared link has a preview image, even if you don't set one per page. + +## What's next + +You now know how to control your meta tags, title templates and social previews. The rest of the docs cover individual features in detail: + +// TODO: add links diff --git a/site/plugins/kirby-seo/docs/0_getting-started/global-seo-settings.png b/site/plugins/kirby-seo/docs/0_getting-started/global-seo-settings.png new file mode 100644 index 0000000..4af3b12 Binary files /dev/null and b/site/plugins/kirby-seo/docs/0_getting-started/global-seo-settings.png differ diff --git a/site/plugins/kirby-seo/docs/0_getting-started/page-seo-inherit.png b/site/plugins/kirby-seo/docs/0_getting-started/page-seo-inherit.png new file mode 100644 index 0000000..7252c5e Binary files /dev/null and b/site/plugins/kirby-seo/docs/0_getting-started/page-seo-inherit.png differ diff --git a/site/plugins/kirby-seo/docs/0_getting-started/page-seo-settings.png b/site/plugins/kirby-seo/docs/0_getting-started/page-seo-settings.png new file mode 100644 index 0000000..271910d Binary files /dev/null and b/site/plugins/kirby-seo/docs/0_getting-started/page-seo-settings.png differ diff --git a/site/plugins/kirby-seo/docs/1_features/00_robots-indexing.md b/site/plugins/kirby-seo/docs/1_features/00_robots-indexing.md new file mode 100644 index 0000000..7c7d06a --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/00_robots-indexing.md @@ -0,0 +1,127 @@ +--- +title: Robots & Indexing +intro: How your pages appear (or don't) in search results +--- + +Search engines and AI providers use programs called crawlers to discover and index pages on the web. You can tell these crawlers which pages they're allowed to index and which ones they should skip. These are not hard blocks: crawlers don't _have_ to follow them. But all major search engines do respect them. + +Kirby SEO does this in two ways: a global `robots.txt` file and per-page `<meta name="robots">` tags. Both are generated automatically. Most of the indexing control happens through meta tags, while `robots.txt` acts as a global safety net. + +## robots.txt + +Kirby SEO generates a `robots.txt` automatically. You don't need to create or maintain it yourself. Visit `example.com/robots.txt` to see yours. + +By default, the output looks like this: + +```txt +User-agent: * +Allow: / +Disallow: /panel + +Sitemap: https://example.com/sitemap.xml +``` + +- `User-agent: *` applies the rules to all crawlers. +- `Allow: /` permits crawling the entire site. +- `Disallow: /panel` blocks the Kirby Panel from being crawled. +- `Sitemap:` points crawlers to your sitemap (only shown when the [sitemap feature](1_features/01_sitemap) is active). + +The `robots.txt` does **not** list individual pages. It only sets broad rules. To control indexing for a specific page, you need meta tags (see below). + +### Debug mode + +When Kirby's debug mode is on, the `robots.txt` blocks all crawlers: + +```txt +User-agent: * +Disallow: / +``` + +This way your development or staging site doesn't end up in search results. + +If you need to customize the `robots.txt`, see [Customizing robots.txt](2_customization/02_robots-txt). + +## Robots meta tags + +The `<meta name="robots">` tag tells search engines what to do with a specific page: whether to index it, follow its links, and more. + +Kirby SEO adds this tag to every page automatically. + +### Default behavior + +The plugin follows page status in Kirby: + +- **Listed** pages are visible to search engines +- **Unlisted** pages are hidden from search engines +- **Draft** pages are not publicly accessible + +In debug mode, **all** pages are hidden from search engines regardless of their status. + +### Overriding robots settings + +Robots meta tags follow the same [Meta Cascade](0_getting-started/1_your-first-meta-tags) as all other fields. The defaults above kick in when nothing else is set, so you can override them: + +- Set a page's robots fields in its **Metadata & SEO** tab to override just that page. +- Set the robots fields on the **Site** to override all pages at once. + +One thing to watch out for: if you hard-set a value at the site level (e.g. setting "Index" to "No" instead of leaving it on "Default"), every page without its own override will follow that setting through the cascade. Leave fields on "Default" if you want the plugin to decide based on page status. + +### Robots indicator in the Panel + +Kirby SEO has a page view button that shows the current robots status at a glance. You need to add it to your page blueprints manually: + +```yaml +# site/blueprints/pages/default.yml +buttons: + - open + - preview + - "-" + - settings + - languages + - status + - robots +``` + +The indicator has three states: + +- **Green**: the page is visible to search engines +- **Yellow**: the page is indexed, but with some restrictions +- **Red**: the page is hidden from search engines + +![Robots indicator showing "Indexing forbidden" in red](robots-indicator.png) + +Clicking it takes you straight to the SEO tab, so you can quickly spot which pages are excluded from search engines. + +### Disabling per-page robots fields + +![Robots directives fields in the Panel](robots-section.png) + +Our suggestion: hide the per-page robots fields unless you actually need them. The defaults are good enough for the vast majority of sites, and the individual settings tend to confuse editors more than they help. You can disable them entirely: + +```php +// site/config/config.php +return [ + 'tobimori.seo' => [ + 'robots' => [ + 'pageSettings' => false, + ], + ], +]; +``` + +This hides the robots fields on both page and site level. The defaults (based on page status and debug mode) still apply. + +For more ways to customize robots behavior, see [Customizing robots.txt](2_customization/02_robots-txt). + +<details> +<summary>Tags suppressed by noindex</summary> + +When a page has `noindex`, Kirby SEO also removes some related tags that don't make sense on a page hidden from search engines: + +- `<link rel="canonical">` is not rendered +- `<meta property="og:url">` is not rendered +- `<link rel="alternate" hreflang="...">` tags are not rendered + +Other tags like `<title>`, `<meta name="description">` and Open Graph tags are still rendered. + +</details> diff --git a/site/plugins/kirby-seo/docs/1_features/01_sitemap.md b/site/plugins/kirby-seo/docs/1_features/01_sitemap.md new file mode 100644 index 0000000..c81c497 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/01_sitemap.md @@ -0,0 +1,35 @@ +--- +title: Sitemap +intro: A sitemap for search engines, generated from your pages +--- + +Kirby SEO generates an XML sitemap at `https://example.com/sitemap.xml`. Search engines like Google use it to discover all the pages on your site. You don't need to create or update it manually: it updates whenever your content changes. + +What you see here are the defaults. The sitemap generator and all its options can be changed or replaced entirely. See [Customizing the sitemap](2_customization/05_sitemap) for details. + +## What's in the sitemap + +The sitemap only includes pages that are [visible to search engines](1_features/00_robots-indexing). Unlisted pages, drafts, and pages excluded by robots settings are left out. The `error` template is also excluded by default. + +Each page in the sitemap includes: + +- `loc`: the page URL +- `lastmod`: when the page was last modified +- `changefreq`: how often the page is likely to change (default: `weekly`) +- `priority`: how important the page is relative to other pages on your site + +Priority is calculated from page depth: the homepage gets `1.0`, and each level deeper subtracts `0.2`, down to a minimum of `0.2`. + +A `Sitemap:` line is also added to your [robots.txt](1_features/00_robots-indexing) automatically, so crawlers know where to find it. + +## Multilingual sites + +If your Kirby site has multiple languages, the sitemap automatically includes `hreflang` links for each page. These tell search engines which language versions of a page exist, so they can show the right one in search results. + +Only languages where a translation actually exists are included. There is no separate sitemap per language: all translations are listed in a single sitemap using `<xhtml:link>` elements. + +## Browser view + +If you open `https://example.com/sitemap.xml` in a browser, you'll see a styled table instead of raw XML. This is powered by an XSL stylesheet that Kirby SEO serves at `/sitemap.xsl`. On multilingual sites, each URL shows language badges linking to its alternate translations. + +To see the raw XML, use `view-source:https://example.com/sitemap.xml` in your browser's address bar. diff --git a/site/plugins/kirby-seo/docs/1_features/02_indexnow.md b/site/plugins/kirby-seo/docs/1_features/02_indexnow.md new file mode 100644 index 0000000..cff4937 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/02_indexnow.md @@ -0,0 +1,56 @@ +--- +title: IndexNow +intro: Notify search engines when your content changes +--- + +Normally, search engines discover changes to your site on their own schedule, which can take days or weeks. [IndexNow](https://www.indexnow.org/) lets you skip the wait: whenever you save, publish, or move a page in Kirby, Kirby SEO notifies search engines so they can re-crawl right away. + +IndexNow is supported by Bing, Yandex, Seznam, and others. Kirby SEO sends a single request to `api.indexnow.org`, which propagates to all participating search engines. Google does not support IndexNow but is not affected by it. + +## How it works + +IndexNow is triggered on three events: + +- A page is saved +- A page changes status (e.g. draft to listed) +- A page's slug changes + +Only pages that are listed and not marked as `noindex` are submitted. On local environments (localhost), no requests are sent. + +## API key + +IndexNow requires an API key to verify that you own the domain. Kirby SEO generates one automatically and caches it permanently. Search engines can verify it at `https://example.com/indexnow-{key}.txt`, which Kirby SEO serves as a route. You don't need to manage this yourself. + +## Related URLs + +By default, only the changed page itself is submitted. But when a page changes, other pages might be affected too: a blog post's parent archive shows a different excerpt, or sibling pages have updated navigation. + +You can configure rules to submit related URLs along with the changed page: + +```php +// site/config/config.php +return [ + 'tobimori.seo' => [ + 'indexnow' => [ + 'rules' => [ + // when a blog post changes, also re-index its parent + '/blog/*' => ['parent' => true], + + // when an article changes, re-index two levels of parents and specific URLs + 'article' => ['parent' => 2, 'urls' => ['/blog', '/']], + + // when a product changes, re-index siblings and all category pages + 'product' => ['parent' => true, 'siblings' => true, 'templates' => ['category']], + ], + ], + ], +]; +``` + +Rules match either by URL pattern (`/blog/*`) or by template name (`article`). Each rule can use any combination of: + +- `parent`: `true` for the direct parent, or a number for how many levels up +- `children`: `true` for all descendants, or a number to limit depth +- `siblings`: `true` to include all pages at the same level +- `urls`: an array of specific URLs to submit +- `templates`: an array of template names, all pages with those templates will be submitted diff --git a/site/plugins/kirby-seo/docs/1_features/03_panel-previews.md b/site/plugins/kirby-seo/docs/1_features/03_panel-previews.md new file mode 100644 index 0000000..9f29e61 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/03_panel-previews.md @@ -0,0 +1,31 @@ +--- +title: Panel Previews +intro: See how your pages look in search results and social shares +--- + +Meta titles and descriptions can look different in context than they do in a text field. The SEO tab in the Panel has a live preview sidebar that shows how the current page will appear when shared or found in search results. It updates as you type, so you can catch issues like truncated titles or missing images before you publish. + +There are three preview types: + +- **Google**: a search result card with your meta title, description, URL and favicon +- **Facebook**: a social sharing card with OG title, description and image +- **Slack**: a link preview card as Slack shows it when someone pastes a URL + +The preview picks up all values through the [Meta Cascade](0_getting-started/1_your-first-meta-tags). If you haven't set an OG title, the preview shows the meta title instead, just like a real crawler would see it. + +Keep in mind that Google sometimes decides to show a different title or description than what you set, if it thinks something else on the page is more relevant to the search query. The preview shows what you _tell_ Google to display, but the actual search result may look different. This is normal and not something we can control. + +On the Site SEO tab, the preview shows data for the homepage since the site itself doesn't have a URL. + +## Choosing which previews to show + +By default, all three previews are available. If you only care about Google and Facebook, you can remove Slack from the list: + +```php +// site/config/config.php +return [ + 'tobimori.seo' => [ + 'previews' => ['google', 'facebook'], + ], +]; +``` diff --git a/site/plugins/kirby-seo/docs/1_features/04_ai-assist.md b/site/plugins/kirby-seo/docs/1_features/04_ai-assist.md new file mode 100644 index 0000000..71edae6 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/04_ai-assist.md @@ -0,0 +1,65 @@ +--- +title: AI Assist +intro: Let AI draft your meta titles and descriptions +--- + +Writing meta titles and descriptions for every page gets tedious fast. AI Assist can generate them for you based on the actual content of each page. It reads the page, looks at your existing meta fields, and drafts a title or description that fits. + +AI Assist works for these fields: + +- Meta title +- Meta description +- Open Graph description +- Site-level meta description +- Site-level Open Graph description + +The generated text matches the language of your page and respects your title template length, so titles don't get cut off in search results. + +## Setting up a provider + +AI Assist needs an API key from an AI provider. Sign up with one of the supported providers and create an API key in their dashboard. Kirby SEO supports [OpenAI](https://platform.openai.com/), [Anthropic](https://console.anthropic.com/), [Google Gemini](https://ai.google.dev/), and [OpenRouter](https://openrouter.ai/) out of the box. OpenRouter is a good starting point because it gives you access to many models through a single API, including models with free tiers. + +AI providers charge based on usage. These costs are separate from your Kirby SEO license. For generating short texts like meta titles and descriptions, costs are typically very low. + +Here's an example using OpenRouter: + +```php +// site/config/config.php +return [ + 'tobimori.seo' => [ + 'ai' => [ + 'provider' => 'openrouter', + 'providers' => [ + 'openrouter' => [ + 'config' => [ + 'apiKey' => 'sk-or-...', + 'model' => 'google/gemini-3-flash-preview', + ], + ], + ], + ], + ], +]; +``` + +For generating meta titles and descriptions, you don't need the most powerful model. Small, fast models work well and keep costs low. Our recommendation is **Google Gemini 3 Flash** via the built-in Gemini provider: it's fast, capable, and has a generous free tier. + +You can change the model for any provider via the `model` key in the config, as shown in the example above. + +For config options for all providers, see [Customizing AI Assist](2_customization/06_ai-assist) for details. + +## Using AI Assist in the Panel + +The provider config is a one-time setup by the developer. Once it's in place, editors just use the buttons in the Panel. + +You'll see new buttons next to the meta title and description fields in the SEO tab. + +The **Generate** button drafts a new value from scratch based on the page content. If the field already has a value, it changes to **Regenerate**. If you want more control, click **Customize** to add your own instructions before generating, like "keep it under 50 characters" or "focus on the pricing". + +Already have a value but want to tweak it? The **Edit** button lets you revise the current text with instructions like "make it shorter" or "add the brand name". + +The result appears word by word. You can stop it early if you want. + +## Custom providers and prompts + +You can add your own providers or override the built-in prompts. See [Customizing AI Assist](2_customization/06_ai-assist) for details. diff --git a/site/plugins/kirby-seo/docs/1_features/05_alt-texts.md b/site/plugins/kirby-seo/docs/1_features/05_alt-texts.md new file mode 100644 index 0000000..57c8eb6 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/05_alt-texts.md @@ -0,0 +1,57 @@ +--- +title: Alt Text Field +intro: Structured alt text for images, with AI generation and a decorative toggle +--- + +Every image on the web needs an `alt` attribute. Images that convey meaning need descriptive text. Decorative images need an empty `alt=""`, which tells screen readers to skip them entirely. Getting this wrong hurts accessibility. + +Kirby SEO provides a dedicated `alt-text` field that handles both cases. It stores structured data instead of a plain string, so your templates always render the correct HTML attributes. + +## Adding the field + +Add a `alt-text` field to any file blueprint: + +```yaml +# site/blueprints/files/image.yml +fields: + alt: + type: alt-text + label: Alt Text +``` + +Editors see a text input with a toggle. The toggle marks an image as decorative: when active, the text input disappears because decorative images don't need a description. + +## AI generation + +If [AI Assist](1_features/04_ai-assist) is configured, the field shows **Generate** and **Customize** buttons. The AI sees the actual image and writes alt text based on it, the filename, and the page context. Results stream in word by word and can be stopped early. + +You can disable AI for a specific field by setting `ai: false` in the blueprint. + +### Auto-generation on upload + +Set `autogenerate: true` to generate alt text automatically when an image is uploaded: + +```yaml +alt: + type: alt-text + autogenerate: true +``` + +By default, this runs synchronously during the upload. For better performance, you can offload it to a background queue. See [Background Processing](2_customization/10_background-processing) for setup. On multilingual sites, a single AI call generates alt text for all languages at once. + +## Using alt text in templates + +The plugin registers a `toAltText()` field method that returns an `AltText` object. Use its `toAttr()` method to get the correct HTML attributes, then spread them into your image helper: + +```php +<?= Html::img($file->url(), [ + 'width' => $file->width(), + 'height' => $file->height(), + ...$file->alt()->toAltText()->toAttr(), +]) ?> +// <img alt="A dog playing fetch" src="..." width="..." height="..."> + +// decorative image: +// <img alt="" src="..." width="..." height="..."> + +The field also works with plain string values from existing `alt` fields. If you migrate from a regular text field, `toAltText()` treats the old value as manual alt text. diff --git a/site/plugins/kirby-seo/docs/1_features/06_google-search-console.md b/site/plugins/kirby-seo/docs/1_features/06_google-search-console.md new file mode 100644 index 0000000..c8cc18b --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/06_google-search-console.md @@ -0,0 +1,29 @@ +--- +title: Google Search Console +intro: See what people search for when they find your pages +--- + +Kirby SEO can pull data from [Google Search Console](https://search.google.com/search-console) directly into the Panel. Editors can see search performance right next to their content, without needing their own Google account or leaving the Panel. You see which search queries lead people to each page, how many clicks and impressions you get, your click-through rate, and your average position in search results. + +![Google Search Console section in the Panel](gsc-section.png) + +The data shows up in a section on both the Site and individual page views. On a page, the queries are filtered to that specific page. On the Site view, you see all queries across your entire site. The section shows the top 10 search queries, sorted by clicks. You can switch the sorting to impressions, CTR, or position. + +Click **Show all** to open a full table with all queries and all four metrics at once. There's also a direct link to open the page in Google Search Console if you want to dig deeper. + +Data is cached for 24 hours, so it won't hit Google's API on every page load. + +## Connecting your Google account + +**IMPORTANT:** The following section describes a feature that is not implemented yet. For now, the Search Console integration requires your own GSC credentials. + +The Google Search Console section needs access to your Google account. To keep setup simple, API requests to Google are proxied through a server operated by Love & Kindness GmbH (the company behind Kirby SEO). This proxy mode requires an active Kirby SEO license, which is used only for rate limiting. We do not log the content of any requests or responses, so we cannot see the actual search data for your site. The source code for the proxy is [open source on GitHub](https://github.com/tobimori/kirby-seo-gsc-proxy). + +1. Open the Panel and navigate to any page with the SEO tab. +2. In the Google Search Console section, click **Connect**. +3. Google asks you to sign in and grant read-only access to your Search Console data. +4. Back in the Panel, select which Search Console property to use. If your domain is already registered in Google Search Console, it will be pre-selected. + +The section starts showing data once the property is selected. + +If you'd rather not use the proxy, you can connect with your own Google OAuth credentials instead. See [Setting up your own GSC credentials](2_customization/07_gsc-setup) for details. diff --git a/site/plugins/kirby-seo/docs/1_features/07_seo-audit.md b/site/plugins/kirby-seo/docs/1_features/07_seo-audit.md new file mode 100644 index 0000000..a58deab --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/07_seo-audit.md @@ -0,0 +1,6 @@ +--- +title: SEO Audit +intro: +--- + +Coming soon diff --git a/site/plugins/kirby-seo/docs/1_features/08_seo-overview.md b/site/plugins/kirby-seo/docs/1_features/08_seo-overview.md new file mode 100644 index 0000000..1efd2f7 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/08_seo-overview.md @@ -0,0 +1,6 @@ +--- +title: SEO Overview +intro: +--- + +Coming soon diff --git a/site/plugins/kirby-seo/docs/1_features/09_utm-share.md b/site/plugins/kirby-seo/docs/1_features/09_utm-share.md new file mode 100644 index 0000000..ae2b83b --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/09_utm-share.md @@ -0,0 +1,42 @@ +--- +title: UTM Share +intro: Share links with tracking parameters for your marketing campaigns +--- + +When you share a link to your site in a newsletter, a social media post, or an ad, you want to know which links actually bring in traffic. UTM parameters are tags you add to a URL so analytics tools like Google Analytics can tell you exactly where a visitor came from. + +A URL with UTM parameters looks like this: + +``` +https://example.com/blog/my-post?utm_source=newsletter&utm_medium=email&utm_campaign=spring-sale +``` + +Kirby SEO adds a **UTM Share** button to your page views. Click it to open a dialog where you can fill in the parameters and copy the resulting URL. + +![UTM Share dialog in the Panel](utm-share.png) + +The dialog has five standard UTM parameters: + +- `utm_source`: where the traffic comes from (e.g. `google`, `newsletter`) +- `utm_medium`: the type of channel (e.g. `cpc`, `email`, `social`) +- `utm_campaign`: the name of the campaign (e.g. `spring_sale`) +- `utm_content`: to tell apart different links in the same campaign (e.g. `logo_link`) +- `utm_term`: the keyword, for paid search ads (e.g. `running shoes`) + +You don't need all five. Most of the time, `utm_source`, `utm_medium`, and `utm_campaign` are enough. + +There's also a `ref` field. This is not part of the UTM standard, but many analytics tools (like Plausible and Pirsch) use it as a lightweight way to track the referring site. + +To add the button to your page blueprints: + +```yaml +# site/blueprints/pages/default.yml +buttons: + - open + - preview + - "-" + - settings + - languages + - status + - utm-share +``` diff --git a/site/plugins/kirby-seo/docs/1_features/10_heading-structure.md b/site/plugins/kirby-seo/docs/1_features/10_heading-structure.md new file mode 100644 index 0000000..46d2a85 --- /dev/null +++ b/site/plugins/kirby-seo/docs/1_features/10_heading-structure.md @@ -0,0 +1,31 @@ +--- +title: Heading Structure +intro: Check your heading hierarchy while editing +--- + +Search engines and screen readers rely on headings (H1, H2, H3, ...) to understand the structure of a page. A well-structured page starts with a single H1 and uses the other levels in order, without skipping any. + +When headings skip levels (e.g. H2 followed by H4) or when there are multiple H1s, search engines have a harder time figuring out what the page is about. Screen readers use the heading tree to let users jump between sections, so broken hierarchy also affects accessibility. + +Most Kirby sites tie heading levels to visual styles: H1 is the largest text, H2 is smaller, and so on. Editors often pick a heading level based on how big they want the text to look, not based on what it means semantically. An H3 after an H1 might look fine on the page, but it tells search engines and screen readers that something is missing. + +Kirby SEO has a Panel section that extracts all headings from the current page and displays them as a nested tree. You see the full hierarchy at a glance, and headings that break the structure are highlighted. The section updates as the page content changes, so editors can fix issues while they write. + +## Adding the section to your blueprint + +Place the section next to your content editor, for example in a sidebar column beside your blocks or layout field: + +```yaml +# site/blueprints/pages/default.yml +tabs: + content: + columns: + - width: 2/3 + fields: + blocks: + type: blocks + - width: 1/3 + sections: + headingStructure: + type: heading-structure +``` diff --git a/site/plugins/kirby-seo/docs/1_features/gsc-section.png b/site/plugins/kirby-seo/docs/1_features/gsc-section.png new file mode 100644 index 0000000..c8f24fc Binary files /dev/null and b/site/plugins/kirby-seo/docs/1_features/gsc-section.png differ diff --git a/site/plugins/kirby-seo/docs/1_features/robots-indicator.png b/site/plugins/kirby-seo/docs/1_features/robots-indicator.png new file mode 100644 index 0000000..16fff67 Binary files /dev/null and b/site/plugins/kirby-seo/docs/1_features/robots-indicator.png differ diff --git a/site/plugins/kirby-seo/docs/1_features/robots-section.png b/site/plugins/kirby-seo/docs/1_features/robots-section.png new file mode 100644 index 0000000..9950cd3 Binary files /dev/null and b/site/plugins/kirby-seo/docs/1_features/robots-section.png differ diff --git a/site/plugins/kirby-seo/docs/1_features/utm-share.png b/site/plugins/kirby-seo/docs/1_features/utm-share.png new file mode 100644 index 0000000..23baf15 Binary files /dev/null and b/site/plugins/kirby-seo/docs/1_features/utm-share.png differ diff --git a/site/plugins/kirby-seo/docs/2_customization/00_programmatic-content.md b/site/plugins/kirby-seo/docs/2_customization/00_programmatic-content.md new file mode 100644 index 0000000..60daa78 --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/00_programmatic-content.md @@ -0,0 +1,84 @@ +--- +title: Programmatic Content +intro: Set default SEO values from page models +--- + +Sometimes you want SEO fields to default to values from other fields, or generate them from code. A common example is using a plugin like [kirby-paparazzi](https://github.com/tobimori/kirby-paparazzi) to generate OG images for every page. + +Add a `metaDefaults` method to a [page model](https://getkirby.com/docs/guide/templates/page-models). It returns an array of meta tag names mapped to their values. These defaults apply through the [Meta Cascade](0_getting-started/1_your-first-meta-tags) when no editor override exists. + +```php +<?php +// site/models/article.php + +use Kirby\Cms\Page; + +class ArticlePage extends Page +{ + public function metaDefaults(string $lang = null): array + { + return [ + 'og:image' => "{$this->url()}.png", + 'og:image:width' => 1230, + 'og:image:height' => 600, + 'description' => $this->content($lang)->summary()->value(), + ]; + } +} +``` + +Kirby SEO picks the correct tag syntax from the name. Open Graph keys (starting with `og:`) get `property` and `content` attributes, link keys like `canonical` get `rel` and `href`, and everything else gets `name` and `content`. + +## Custom tag attributes + +If you need full control over a tag's output, pass an array with `tag` and `attributes`: + +```php +return [ + // shorthand + 'description' => 'A page about something', + + // tag with inner content + [ + 'tag' => 'title', + 'content' => 'My Page Title', + ], + + // tag with attributes + [ + 'tag' => 'meta', + 'attributes' => [ + 'property' => 'og:image:alt', + 'content' => "An image of {$this->title()}", + ], + ], + + // link tag + [ + 'tag' => 'link', + 'attributes' => [ + 'rel' => 'preconnect', + 'href' => 'https://fonts.googleapis.com', + ], + ], +]; +``` + +## Global defaults via a plugin + +Page models only apply to pages with a specific template. If you want to add meta tags to all pages, you can register a `metaDefaults` [page method](https://getkirby.com/docs/reference/plugins/extensions/page-methods) in a plugin: + +```php +<?php +// site/plugins/my-meta/index.php + +Kirby::plugin('my/meta', [ + 'pageMethods' => [ + 'metaDefaults' => function (string $lang = null): array { + return [ + 'og:image' => "{$this->url()}.png", + ]; + }, + ], +]); +``` diff --git a/site/plugins/kirby-seo/docs/2_customization/01_meta-cascade.md b/site/plugins/kirby-seo/docs/2_customization/01_meta-cascade.md new file mode 100644 index 0000000..d577be8 --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/01_meta-cascade.md @@ -0,0 +1,95 @@ +--- +title: Meta Cascade +intro: Understand how meta values are resolved across multiple levels +--- + +Kirby SEO is built with a cascading approach. Meta tags can be defined on multiple levels, and they are merged based on priority. If a value is empty on one level, it falls through to the next. This is how the plugin forms the final metadata for every page. + +The default cascade, in order of priority: + +1. **Page fields** (`fields`) -- Values the editor enters in the page's SEO blueprint fields. This is the highest priority: if an editor sets a meta description, it always wins. + +2. **Programmatic** (`programmatic`) -- Values returned by `metaDefaults()` in [page models](2_customization/00_programmatic-content). Use this for computed defaults like generated OG images or descriptions derived from other fields. + +3. **Parent** (`parent`) -- Inherited values from the parent page. If a parent page has "inherit settings" enabled for a field, its children pick up those values. Useful for giving all blog posts the same title template, for example. + +4. **Fallback fields** (`fallbackFields`) -- Falls back to meta field values for Open Graph tags. If no `ogDescription` is set, the page's `metaDescription` is used instead. + +5. **Site** (`site`) -- Global values from the site's SEO blueprint fields. These apply to all pages that don't have their own value set at a higher level. + +6. **Options** (`options`) -- The final fallback, defined in the plugin's config defaults. These are the built-in defaults like the title template `{{ title }} - {{ site.title }}`. + +## Configuring the cascade + +The cascade order is configurable in your `config.php`. You can remove levels, reorder them, or add optional ones: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'cascade' => [ + 'fields', + 'programmatic', + 'parent', + 'fallbackFields', + 'site', + 'options', + ], + ], +]; +``` + +Remove an entry to skip that level entirely. For example, to disable parent inheritance: + +```php +'cascade' => [ + 'fields', + 'programmatic', + 'fallbackFields', + 'site', + 'options', +], +``` + +## Restore the 1.x behavior + +In 1.x, if you set an `ogDescription` at the site level, it applied to every page, even pages that had their own `metaDescription`. The page-specific description never made it into the Open Graph tags. + +In 2.x, the `fallbackFields` level sits between `parent` and `site`, so a page's `metaDescription` is used as `ogDescription` before site-wide Open Graph values are reached. + +To restore the 1.x behavior, remove `fallbackFields` from the cascade: + +```php +'cascade' => [ + 'fields', + 'programmatic', + 'parent', + 'site', + 'options', +], +``` + +<details> +<summary>If you used <code>fallbackFields</code> with additional mappings in 1.x</summary> + +In 1.x, `fallbackFields` also mapped `ogTemplate` to `metaTemplate`. If you relied on this, you can restore it by extending the `Meta` class and overriding the `FALLBACK_MAP` constant: + +```php +<?php + +use tobimori\Seo\Meta; + +class MyMeta extends Meta +{ + public const FALLBACK_MAP = [ + 'ogDescription' => 'metaDescription', + 'ogTemplate' => 'metaTemplate', + ]; +} +``` + +Then register your class in the config. See [Extending the Plugin](2_customization/11_plugin-extensions) for details. + +</details> diff --git a/site/plugins/kirby-seo/docs/2_customization/02_robots-txt.md b/site/plugins/kirby-seo/docs/2_customization/02_robots-txt.md new file mode 100644 index 0000000..a19bb75 --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/02_robots-txt.md @@ -0,0 +1,66 @@ +--- +title: Customizing robots.txt +intro: Add custom rules to your robots.txt +--- + +By default, Kirby SEO generates a simple `robots.txt` that allows all crawlers and blocks the Panel. If you need to add your own rules, use the `robots.content` option. + +## Blocking specific bots + +Some AI providers crawl websites to use the content as training data. You can block their crawlers: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'robots' => [ + 'content' => [ + 'GPTBot' => [ + 'Disallow' => ['/'], + ], + 'Google-Extended' => [ + 'Disallow' => ['/'], + ], + 'CCBot' => [ + 'Disallow' => ['/'], + ], + ], + ], + ], +]; +``` + +This adds rules for each bot while keeping the default rules for all other crawlers intact. + +## Custom rules for all crawlers + +If you set rules for `*`, they replace the default rules entirely: + +```php +'content' => [ + '*' => [ + 'Allow' => ['/'], + 'Disallow' => ['/panel', '/content', '/private'], + ], +], +``` + +## Mixing rules + +You can combine rules for all crawlers with rules for specific bots: + +```php +'content' => [ + '*' => [ + 'Allow' => ['/'], + 'Disallow' => ['/panel', '/content'], + ], + 'GPTBot' => [ + 'Disallow' => ['/'], + ], +], +``` + +The `Sitemap:` line is added automatically if the [sitemap module](1_features/01_sitemap) is active. You can override it with the `robots.sitemap` option. diff --git a/site/plugins/kirby-seo/docs/2_customization/03_robots-noai.md b/site/plugins/kirby-seo/docs/2_customization/03_robots-noai.md new file mode 100644 index 0000000..9058505 --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/03_robots-noai.md @@ -0,0 +1,27 @@ +--- +title: Opting Out of AI Training +intro: Signal to AI crawlers that your content should not be used for training +--- + +The `noai` and `noimageai` robot directives tell AI crawlers not to use your content or images for training. These are not an official standard, but were introduced by [DeviantArt and Spawning](https://www.deviantart.com/team/journal/UPDATE-All-Deviations-Are-Opted-Out-of-AI-Datasets-934500371) and are respected by some AI providers. Like all robot directives, they are signals, not hard blocks. + +Kirby SEO has a `types` option that controls which robot directives are available. Add `ai` and `imageai` to the list: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'robots' => [ + 'types' => ['index', 'follow', 'archive', 'imageindex', 'snippet', 'ai', 'imageai'], + ], + ], +]; +``` + +The new fields show up in the robots section of the SEO tab. If you previously disabled `robots.pageSettings`, you need to re-enable it for the fields to appear. + +By default, all directives are set to "Yes" (allowed). To opt out of AI training, an editor needs to set the AI Training and AI Image Training fields to "No". The plugin then outputs `noai` and `noimageai` in the robots meta tag. + +If you want to opt out for all pages at once, set it on the Site level instead of per page. Translations for the field labels are included in the plugin. diff --git a/site/plugins/kirby-seo/docs/2_customization/05_sitemap.md b/site/plugins/kirby-seo/docs/2_customization/05_sitemap.md new file mode 100644 index 0000000..268ae6c --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/05_sitemap.md @@ -0,0 +1,77 @@ +--- +title: Customizing the Sitemap +intro: Fine-tune the built-in sitemap or replace it entirely +--- + +The built-in sitemap generator has a few options to adjust its behavior. For most sites, these are enough. If you need full control, you can replace the generator with your own. + +## Excluding templates + +By default, only the `error` template is excluded. To exclude more templates: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'sitemap' => [ + 'excludeTemplates' => ['error', 'redirect', 'internal'], + ], + ], +]; +``` + +## Grouping by template + +By default, all pages end up in a single sitemap. If you have many pages, you can split them into separate sitemaps per template. This creates a sitemap index at `/sitemap.xml` with links to `/sitemap-blog.xml`, `/sitemap-product.xml`, etc. + +```php +'sitemap' => [ + 'groupByTemplate' => true, +], +``` + +## Change frequency and priority + +Both `changefreq` and `priority` accept a static value or a callable: + +```php +'sitemap' => [ + 'changefreq' => 'daily', + 'priority' => fn (Page $page) => $page->isHomePage() ? 1.0 : 0.5, +], +``` + +The default `changefreq` is `weekly`. The default `priority` is calculated from page depth: the homepage gets `1.0`, each level deeper subtracts `0.2`, down to `0.2`. + +## Writing your own generator + +If the options above aren't enough, you can replace the entire sitemap generator. The `generator` option takes a callable that receives a `SitemapIndex` instance. Here's a minimal example: + +```php +<?php + +use tobimori\Seo\Sitemap\SitemapIndex; + +return [ + 'tobimori.seo' => [ + 'sitemap' => [ + 'generator' => function (SitemapIndex $sitemap) { + $index = $sitemap->create('pages'); + + foreach (site()->index()->listed() as $page) { + $index->createUrl($page->url()) + ->lastmod($page->modified()) + ->changefreq('weekly') + ->priority(0.8); + } + }, + ], + ], +]; +``` + +`$sitemap->create('key')` creates a sitemap group. `$index->createUrl($url)` adds a URL entry, and you can chain `->lastmod()`, `->changefreq()`, `->priority()`, and `->alternates()` on it. + +The built-in generator does more: it filters by robots settings, respects `excludeTemplates`, handles `groupByTemplate`, and adds hreflang links for multilingual sites. You can find its source in `config/options/sitemap.php` as a reference for your own. diff --git a/site/plugins/kirby-seo/docs/2_customization/06_ai-assist.md b/site/plugins/kirby-seo/docs/2_customization/06_ai-assist.md new file mode 100644 index 0000000..f9e2b2b --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/06_ai-assist.md @@ -0,0 +1,134 @@ +--- +title: Customizing AI Assist +intro: Override prompts or add your own AI provider +--- + +## Overriding prompts + +AI Assist uses Kirby snippets for its prompts. You can override any of them by creating a snippet with the same path in your project. + +The built-in prompt snippets are: + +- `seo/prompts/tasks/title` - Meta title generation +- `seo/prompts/tasks/description` - Meta description generation +- `seo/prompts/tasks/og-description` - Open Graph description generation +- `seo/prompts/tasks/site-description` - Site-level meta description +- `seo/prompts/tasks/og-site-description` - Site-level OG description + +To override the meta title prompt, create `site/snippets/seo/prompts/tasks/title.php` in your project. Kirby's snippet loading will pick up your version instead of the built-in one. + +Each prompt snippet receives these variables: + +- `$page` - the current page +- `$site` - the site object +- `$instructions` - custom instructions from the editor (if any) +- `$edit` - the existing text when editing (if any) + +There are also shared snippets that the task prompts include: + +- `seo/prompts/introduction` - Defines the AI's role and rules +- `seo/prompts/content` - Extracts the page content +- `seo/prompts/meta` - Shows existing metadata for context + +You can override these too. Look at the built-in prompts in `site/plugins/kirby-seo/snippets/prompts/` to understand their structure before writing your own. + +## Adding a custom provider + +If you need a provider that isn't built in, you can add your own. A provider has two parts: a driver class that handles the API communication, and a config entry that registers it. + +Create a class that extends `tobimori\Seo\Ai\Driver`. The only method you need to implement is `stream`, which receives a prompt string and must yield `Chunk` objects as the response comes in. + +```php +<?php + +namespace App\Ai; + +use Generator; +use tobimori\Seo\Ai\Chunk; +use tobimori\Seo\Ai\Driver; +use tobimori\Seo\Ai\SseStream; + +class MyProvider extends Driver +{ + public function stream(string $prompt, string|null $model = null): Generator + { + $apiKey = $this->config('apiKey', required: true); + $model = $model ?? $this->config('model', 'default-model'); + $endpoint = $this->config('endpoint', required: true); + + $stream = new SseStream($endpoint, [ + 'Content-Type: application/json', + 'Accept: text/event-stream', + "Authorization: Bearer {$apiKey}", + ], [ + 'model' => $model, + 'input' => $prompt, + 'stream' => true, + ], (int)$this->config('timeout', 120)); + + yield from $stream->stream(function (array $event): Generator { + $type = $event['type'] ?? null; + + if ($type === 'start') { + yield Chunk::streamStart($event); + } + + if ($type === 'delta') { + yield Chunk::textDelta($event['text'] ?? '', $event); + } + + if ($type === 'done') { + yield Chunk::streamEnd($event); + } + + if ($type === 'error') { + yield Chunk::error($event['message'] ?? 'Unknown error', $event); + } + }); + } +} +``` + +The driver uses `$this->config()` to read values from the provider's `config` array in `config.php`. Pass `required: true` to throw an error if a value is missing. + +`SseStream` is a helper class included in Kirby SEO that handles the cURL request and SSE parsing. You pass it the endpoint, headers, payload, and a mapper function that converts raw SSE events into `Chunk` objects. + +If your API doesn't use SSE, you can skip `SseStream` and yield chunks directly. + +The chunks the Panel expects, in order: + +1. `Chunk::streamStart()` - Signals the stream has started +2. `Chunk::textDelta($text)` - Each piece of generated text (repeated) +3. `Chunk::textComplete()` - The text is done +4. `Chunk::streamEnd()` - The stream is finished + +If something goes wrong, yield `Chunk::error($message)` at any point. + +## Registering the provider + +Add your driver to the config and set it as the active provider: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'ai' => [ + 'provider' => 'myprovider', + 'providers' => [ + 'myprovider' => [ + 'driver' => \App\Ai\MyProvider::class, + 'config' => [ + 'apiKey' => 'sk-...', + 'model' => 'my-model', + 'endpoint' => 'https://api.example.com/v1/chat', + ], + ], + ], + ], + ], +]; +``` + +See the built-in drivers in `site/plugins/kirby-seo/classes/Ai/Drivers/` for complete implementations. diff --git a/site/plugins/kirby-seo/docs/2_customization/07_gsc-setup.md b/site/plugins/kirby-seo/docs/2_customization/07_gsc-setup.md new file mode 100644 index 0000000..67fb554 --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/07_gsc-setup.md @@ -0,0 +1,45 @@ +--- +title: Setting up Google Search Console +intro: Connect Search Console with your own Google OAuth credentials +--- + +By default, the Search Console integration uses a proxy to keep setup simple. If you'd rather connect directly, you can set up your own Google OAuth credentials instead. This requires a Google Cloud project with the Search Console API enabled. The API is free to use. + +## Create OAuth credentials + +Go to the [Google Cloud Console](https://console.cloud.google.com/) and create a new project, or use an existing one. + +Navigate to **APIs & Services** → **Credentials** → **Create Credentials** → **OAuth client ID** and configure it: + +- **Application type:** Web application +- **Name:** e.g. "Kirby SEO on example.com" +- **Authorized redirect URIs:** your site URL followed by `/__seo/gsc/callback`, e.g. `https://example.com/__seo/gsc/callback` + +Download the JSON file when prompted. You'll need it in the next step. + +Then go to **APIs & Services** → **Library**, search for "Google Search Console API" and enable it. Without this, the OAuth flow will succeed but the API requests will fail. + +## Add credentials to your config + +Place the downloaded JSON file in your `site/config` directory (e.g. `site/config/gsc-credentials.json`), then reference it in your config: + +```php +<?php +// site/config/config.php + +use Kirby\Data\Json; + +return [ + 'tobimori.seo' => [ + 'searchConsole' => [ + 'credentials' => Json::read(__DIR__ . '/gsc-credentials.json'), + ], + ], +]; +``` + +## Connect in the Panel + +Open the Panel and navigate to any page with the SEO tab. The Google Search Console section now shows a **Connect** button. Click it and authorize with your Google account. Make sure the Google account you use has access to the Search Console property for your site. + +After authorizing, select which Search Console property to use. The section starts showing data once the property is selected. diff --git a/site/plugins/kirby-seo/docs/2_customization/08_schema-org.md b/site/plugins/kirby-seo/docs/2_customization/08_schema-org.md new file mode 100644 index 0000000..c2a064f --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/08_schema-org.md @@ -0,0 +1,89 @@ +--- +title: Schema.org (JSON-LD) +intro: Add structured data to your pages +--- + +Kirby SEO can output Schema.org structured data as JSON-LD. It uses the [spatie/schema-org](https://github.com/spatie/schema-org) package, which must be installed separately: + +```bash +composer require spatie/schema-org +``` + +Once installed, a `WebSite` schema is generated automatically for every page with the page's title, description, and canonical URL. You can build on top of this or add your own schemas. + +## Adding structured data + +The plugin exposes a global store for Schema.org objects. You can access it from templates, snippets, or block snippets using `$page->schema()` and `$site->schema()`. Calling the same type twice returns the same instance, so you can build up a schema across different files. + +```php +<?php +// site/templates/article.php + +$page->schema('Article') + ->headline($page->title()->value()) + ->datePublished($page->date()->toDate('c')) + ->author( + schema('Person') + ->name($page->author()->value()) + ); +``` + +`$page->schema($type)` returns the stored schema for that type, or creates a new one if it doesn't exist yet. Both also exist as `$site->schema()` and `$site->schemas()` for site-level schemas. + +The global `schema($type)` function creates a new instance without storing it. Use it for nested objects like the `Person` above that don't need their own top-level entry. + +## Building schemas across blocks + +Because `$page->schema()` always returns the same instance, you can add to a schema from individual block snippets. This is useful for types like `FAQPage` where the content comes from multiple blocks: + +```php +<?php +// site/snippets/blocks/faq.php + +$page->schema('FAQPage') + ->mainEntity([ + ...($page->schema('FAQPage')->getProperty('mainEntity') ?? []), + schema('Question') + ->name($block->question()) + ->acceptedAnswer( + schema('Answer')->text($block->answer()) + ), + ]); +``` + +Each block appends its question to the `mainEntity` array. The final output combines all of them: + +```json +{ + "@context": "https://schema.org", + "@type": "FAQPage", + "mainEntity": [ + { + "@type": "Question", + "name": "How does it work?", + "acceptedAnswer": { + "@type": "Answer", + "text": "It works like this." + } + }, + { + "@type": "Question", + "name": "Can it handle multiple blocks?", + "acceptedAnswer": { + "@type": "Answer", + "text": "Yes, it can." + } + } + ] +} +``` + +## Disabling the default schema + +If you don't want the automatic `WebSite` schema, disable it in your config: + +```php +'tobimori.seo' => [ + 'generateSchema' => false, +], +``` diff --git a/site/plugins/kirby-seo/docs/2_customization/09_optimizing-head-order.md b/site/plugins/kirby-seo/docs/2_customization/09_optimizing-head-order.md new file mode 100644 index 0000000..b9e457f --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/09_optimizing-head-order.md @@ -0,0 +1,21 @@ +--- +title: Optimizing Head Order +intro: Place high-priority elements before stylesheets and scripts +--- + +The order of elements in the `<head>` can affect perceived page performance. Ideally, the `<title>` element should appear early, before stylesheets and scripts, while other meta tags like Open Graph and description can go last. See [capo.js](https://rviscomi.github.io/capo.js/) for background on why this matters. + +By default, `seo/head` outputs all tags in one block. If you want to split priority tags from the rest, use Kirby's [snippet slots](https://getkirby.com/docs/guide/templates/snippets#passing-data-to-snippets__slots): + +```php +<head> + <meta charset="utf-8"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + <?php snippet('seo/head', slots: true) ?> + <link rel="stylesheet" href="/assets/css/main.css"> + <script src="/assets/js/app.js" defer></script> + <?php endsnippet() ?> +</head> +``` + +This outputs the `<title>` first, then your stylesheets and scripts from the slot, then the remaining meta tags (description, Open Graph, robots, etc.). diff --git a/site/plugins/kirby-seo/docs/2_customization/10_background-processing.md b/site/plugins/kirby-seo/docs/2_customization/10_background-processing.md new file mode 100644 index 0000000..21d6d74 --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/10_background-processing.md @@ -0,0 +1,6 @@ +--- +title: Setup Background Processing +intro: +--- + +Coming soon diff --git a/site/plugins/kirby-seo/docs/2_customization/11_plugin-extensions.md b/site/plugins/kirby-seo/docs/2_customization/11_plugin-extensions.md new file mode 100644 index 0000000..c140cbe --- /dev/null +++ b/site/plugins/kirby-seo/docs/2_customization/11_plugin-extensions.md @@ -0,0 +1,47 @@ +--- +title: Extending the Plugin +intro: Replace built-in classes with your own +--- + +Kirby SEO uses a component system similar to [Kirby's own](https://getkirby.com/docs/reference/plugins/components). Every major class in the plugin can be swapped out for a custom one. This lets you change how the plugin works without forking it. + +The built-in components are: + +| Key | Default class | Handles | +| ---------- | ---------------------------------- | --------------------------------- | +| `meta` | `tobimori\Seo\Meta` | Meta tag generation and cascading | +| `ai` | `tobimori\Seo\Ai` | AI Assist provider management | +| `indexnow` | `tobimori\Seo\IndexNow` | IndexNow ping requests | +| `schema` | `tobimori\Seo\SchemaSingleton` | Schema.org structured data store | +| `gsc` | `tobimori\Seo\GoogleSearchConsole` | Google Search Console integration | + +To replace a component, create a class that extends the original. For example, to customize meta tag output, extend the `Meta` class: + +```php +<?php +// site/plugins/my-seo/index.php + +use tobimori\Seo\Meta; + +class MyMeta extends Meta +{ + // override any method you need +} +``` + +Then register your class in the config: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'components' => [ + 'meta' => MyMeta::class, + ], + ], +]; +``` + +The rest of the plugin picks up your class automatically. Page methods, hooks, routes, and sections all resolve components through the config, so your class is used everywhere the original would have been. Look at the built-in classes in `site/plugins/kirby-seo/classes/` to see what methods are available to override. diff --git a/site/plugins/kirby-seo/docs/3_reference/0_options.md b/site/plugins/kirby-seo/docs/3_reference/0_options.md new file mode 100644 index 0000000..b113ccd --- /dev/null +++ b/site/plugins/kirby-seo/docs/3_reference/0_options.md @@ -0,0 +1,157 @@ +--- +title: Options +intro: All configuration options +--- + +All options are set under `tobimori.seo` in your `config.php`. Dots in the option names represent nested arrays. For example, `robots.enabled` becomes: + +```php +<?php +// site/config/config.php + +return [ + 'tobimori.seo' => [ + 'robots' => [ + 'enabled' => true, + ], + ], +]; +``` + +You can also use Kirby's flat dot syntax: + +```php +return [ + 'tobimori.seo.robots.enabled' => true, +]; +``` + +Both are equivalent, but you cannot use dot syntax inside a nested array. `'robots.enabled' => true` only works at the top level as `'tobimori.seo.robots.enabled'`. Inside the `'tobimori.seo'` array, you must use nested arrays. + +## General + +| Option | Default | Description | +| ------------------------- | --------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------- | +| `locale` | `'en_US'` | Default locale for single-language sites | +| `dateFormat` | `null` | Custom date format for dates in meta tags | +| `generateSchema` | `true` | Generate a default `WebSite` schema for every page. Requires [spatie/schema-org](2_customization/08_schema-org) | +| `previews` | `['google', 'facebook', 'slack']` | Which preview types to show in the Panel | +| `cascade` | `['fields', 'programmatic', 'parent', 'fallbackFields', 'site', 'options']` | The [meta cascade](2_customization/01_meta-cascade) order | +| `canonical.base` | `null` | Base URL for canonical links. Uses the site URL if not set | +| `canonical.trailingSlash` | `false` | Add trailing slashes to canonical URLs | +| `files.parent` | `null` | Default parent page for file uploads in SEO fields | +| `files.template` | `null` | Default file template for SEO file uploads | +| `socialMedia` | See below | Social media account fields shown in the site blueprint | + +The `socialMedia` option defines which fields appear in the site blueprint. Default fields: `twitter`, `facebook`, `instagram`, `youtube`, `linkedin`, `bluesky`, `mastodon`. Each key maps to a placeholder URL. Override the array to add or remove fields. + +## Meta defaults + +These are the fallback values for the last level of the [meta cascade](2_customization/01_meta-cascade). They apply when no other level provides a value. Each option can be a static value or a callable that receives the `Page` object. + +| Option | Default | Description | +| -------------------------- | ---------------------------------- | ---------------------------------------------------------- | +| `default.metaTitle` | Page title | Meta title | +| `default.metaTemplate` | `'{{ title }} - {{ site.title }}'` | Title template applied to all pages | +| `default.ogTemplate` | `'{{ title }}'` | Open Graph title template | +| `default.ogSiteName` | Site title | Open Graph site name | +| `default.ogType` | `'website'` | Open Graph type | +| `default.ogDescription` | Meta description | Open Graph description, falls back to the meta description | +| `default.cropOgImage` | `true` | Crop OG images to 1200x630 | +| `default.locale` | Language locale or `'en_US'` | Locale for meta tags | +| `default.robotsIndex` | `true` if listed and not debug | Whether pages are indexable | +| `default.robotsFollow` | Same as `robotsIndex` | Whether links are followed | +| `default.robotsArchive` | Same as `robotsIndex` | Whether archiving is allowed | +| `default.robotsImageindex` | Same as `robotsIndex` | Whether image indexing is allowed | +| `default.robotsSnippet` | Same as `robotsIndex` | Whether snippets are allowed | + +## Robots + +| Option | Default | Description | +| ------------------------- | --------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- | +| `robots.enabled` | `true` | Whether the plugin handles robots meta tags and robots.txt | +| `robots.index` | `true` (unless debug mode) | Site-wide indexing default. Set to `false` to noindex the entire site | +| `robots.followPageStatus` | `true` | Unlisted pages are noindex by default | +| `robots.pageSettings` | `true` | Show robots settings on each page in the Panel | +| `robots.types` | `['index', 'follow', 'archive', 'imageindex', 'snippet']` | Available robot directive types. Add `'ai'` and `'imageai'` for [AI training controls](2_customization/03_robots-noai) | +| `robots.content` | `[]` | Custom [robots.txt rules](2_customization/02_robots-txt) per user agent | +| `robots.sitemap` | `null` | Custom sitemap URL for robots.txt. Auto-detected when the sitemap module is active | + +## Sitemap + +| Option | Default | Description | +| -------------------------- | --------------------- | ------------------------------------------------------------------------------------------------------------- | +| `sitemap.enabled` | `true` | Whether to generate a sitemap | +| `sitemap.redirect` | `true` | Redirect `/sitemap` to `/sitemap.xml` | +| `sitemap.locale` | `'en'` | Locale for the sitemap XSL stylesheet | +| `sitemap.generator` | Built-in generator | A callable that receives a `SitemapIndex` instance. See [customizing the sitemap](2_customization/05_sitemap) | +| `sitemap.changefreq` | `'weekly'` | Default change frequency. Static value or callable | +| `sitemap.priority` | Calculated from depth | Homepage gets `1.0`, each level deeper subtracts `0.2`, minimum `0.2` | +| `sitemap.groupByTemplate` | `false` | Split the sitemap into separate files per template | +| `sitemap.excludeTemplates` | `['error']` | Templates to exclude from the sitemap | + +## AI Assist + +| Option | Default | Description | +| -------------- | ---------- | --------------------------------- | +| `ai.enabled` | `true` | Whether AI features are available | +| `ai.provider` | `'openai'` | The active provider ID | +| `ai.providers` | See below | Provider configurations | + +Each provider has a `driver` class and a `config` array. The config options depend on the driver. All built-in drivers share `apiKey` (required), `model`, `endpoint`, and `timeout`. The OpenAI driver also accepts `organization`. + +| Provider | Driver | Default model | Default endpoint | +| ------------ | ----------- | -------------------------------- | --------------------------------------------------------- | +| `openai` | `OpenAi` | `gpt-5-mini-2025-08-07` | `https://api.openai.com/v1/responses` | +| `anthropic` | `Anthropic` | `claude-4-5-haiku` | `https://api.anthropic.com/v1/messages` | +| `gemini` | `Gemini` | `gemini-3.1-flash-lite-preview` | `https://generativelanguage.googleapis.com/v1beta` | +| `openrouter` | `OpenAi` | `openai/gpt-5-nano` | `https://openrouter.ai/api/v1/responses` | + +The Gemini driver authenticates via API key as a query parameter (not a header). All providers default to a timeout of 120 seconds. See [customizing AI Assist](2_customization/06_ai-assist) for adding your own provider. + +## IndexNow + +| Option | Default | Description | +| ----------------------- | ---------------------------- | ---------------------------------------------------------- | +| `indexnow.enabled` | `true` | Whether to ping search engines on page changes | +| `indexnow.searchEngine` | `'https://api.indexnow.org'` | IndexNow API endpoint. One engine propagates to all others | +| `indexnow.rules` | `[]` | Invalidation rules for related pages | + +Rules map a match pattern to invalidation targets. Match patterns can be a URL glob (`'/blog/*'`), a template name (`'article'`), or a wildcard (`'*'`). + +| Target | Value | Description | +| ----------- | --------------- | ---------------------------------------------------------- | +| `parent` | `true` or `int` | Invalidate the direct parent (`true`) or N levels up | +| `children` | `true` or `int` | Invalidate all descendants (`true`) or up to N levels deep | +| `siblings` | `true` | Invalidate all siblings at the same level | +| `urls` | `string[]` | Specific URLs to invalidate | +| `templates` | `string[]` | Invalidate all pages with these templates | + +```php +'indexnow' => [ + 'rules' => [ + 'article' => ['parent' => true, 'urls' => ['/blog', '/']], + 'product' => ['parent' => true, 'siblings' => true, 'templates' => ['category']], + ], +], +``` + +## Search Console + +| Option | Default | Description | +| --------------------------- | ------------------------------ | ----------------------------------------------------------------------------- | +| `searchConsole.enabled` | `true` | Whether the Search Console integration is active | +| `searchConsole.credentials` | `null` | Google OAuth credentials array. See [GSC setup](2_customization/07_gsc-setup) | +| `searchConsole.tokenPath` | `site/config/.gsc-tokens.json` | Where OAuth tokens are stored | + +## Components + +| Option | Default | Description | +| --------------------- | ---------------------------------- | ------------------------- | +| `components.meta` | `tobimori\Seo\Meta` | Meta tag generation class | +| `components.ai` | `tobimori\Seo\Ai` | AI Assist class | +| `components.indexnow` | `tobimori\Seo\IndexNow` | IndexNow class | +| `components.schema` | `tobimori\Seo\SchemaSingleton` | Schema.org store class | +| `components.gsc` | `tobimori\Seo\GoogleSearchConsole` | Search Console class | + +See [extending the plugin](2_customization/11_plugin-extensions) for details on replacing components. diff --git a/site/plugins/kirby-seo/docs/3_reference/1_permissions.md b/site/plugins/kirby-seo/docs/3_reference/1_permissions.md new file mode 100644 index 0000000..b073731 --- /dev/null +++ b/site/plugins/kirby-seo/docs/3_reference/1_permissions.md @@ -0,0 +1,37 @@ +--- +title: Permissions +intro: Control access to plugin features by user role +--- + +Kirby SEO registers permissions that you can restrict per [user role](https://getkirby.com/docs/guide/users/permissions). By default, all permissions are granted. + +## Available permissions + +| Permission | Controls | +| ----------------- | -------------------------------------------------------------------------------- | +| `tobimori.seo.ai` | Access to all AI Assist features: generating, editing, and customizing meta text | + +More permissions will be added in future releases. + +## Restricting access + +Set a permission to `false` in a role's blueprint to deny it: + +```yaml +# site/blueprints/users/editor.yml + +title: Editor +permissions: + tobimori.seo: + ai: false +``` + +You can also deny all current and future permissions at once using a wildcard: + +```yaml +permissions: + tobimori.seo: + *: false +``` + +Users without a permission will not see the corresponding UI elements in the Panel, and API requests will be rejected. diff --git a/site/plugins/kirby-seo/index.css b/site/plugins/kirby-seo/index.css new file mode 100644 index 0000000..82a12e8 --- /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-alt-text-field .k-input{min-height:var(--input-height)}.k-alt-text-field .k-textarea-input-native{min-width:0;padding:var(--input-padding);resize:none;margin-block:-1.5px}.k-alt-text-field.is-decorative .k-alt-text-header{grid-template-columns:1fr}.k-alt-text-field.is-decorative .k-alt-text-toggle.k-button{--button-align: flex-start;margin-inline:.25rem}.k-alt-text-field.is-decorative .k-textarea-input-native{display:none}.k-alt-text-header{display:grid;grid-template-columns:max-content minmax(0,1fr);align-items:center;min-height:inherit}.k-alt-text-toggle.k-button{--button-height: var(--height-sm);--button-rounded: var(--rounded-sm);--button-color-back: var(--panel-color-back);margin-inline-start:.25rem}.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..9ca020a --- /dev/null +++ b/site/plugins/kirby-seo/index.js @@ -0,0 +1,5 @@ +(function(){"use strict";const i=window.Vue;function y(){return window.panel}function A(){return y().api}function N(){return y().app}function V(){return N().$library}function I(){const o=A();return{load:({parent:t,name:s})=>o.get(`${t}/sections/${s}`)}}const v=i.computed;i.customRef,i.defineAsyncComponent,i.defineComponent,i.effectScope,i.getCurrentInstance,i.getCurrentScope,i.h,i.inject,i.isProxy,i.isReactive,i.isReadonly,i.isRef,i.isShallow,i.markRaw;const P=i.nextTick;i.onActivated,i.onBeforeMount;const H=i.onBeforeUnmount;i.onBeforeUpdate,i.onDeactivated,i.onErrorCaptured;const T=i.onMounted;i.onRenderTracked,i.onRenderTriggered,i.onScopeDispose,i.onServerPrefetch;const L=i.onUnmounted;i.onUpdated,i.provide,i.proxyRefs,i.reactive,i.readonly;const g=i.ref;i.shallowReactive,i.shallowReadonly,i.shallowRef,i.toRaw,i.toRef,i.toRefs,i.triggerRef,i.unref,i.useAttrs,i.useCssModule,i.useCssVars,i.useListeners,i.useSlots;const E=i.watch;i.watchEffect,i.watchPostEffect,i.watchSyncEffect;async function q(o,e){const t=new TextDecoder;let s="";try{for(;;){const{value:a,done:n}=await o.read();if(n)break;a&&(s+=t.decode(a,{stream:!0}),s=O(s,e))}s+=t.decode(),O(s,e)}finally{o&&typeof o.releaseLock=="function"&&o.releaseLock()}}function O(o,e){let t=o;for(;;){const s=t.indexOf(` + +`);if(s===-1)return t;const a=t.slice(0,s);if(t=t.slice(s+2),a.trim()==="")continue;const n=a.split(` +`).filter(r=>r.trim().startsWith("data:")).map(r=>r.trim().slice(5)).join(` +`).trim();if(n==="")continue;let l;try{l=JSON.parse(n)}catch(r){console.error("Failed to parse SSE event",r,n);continue}e(l)}}async function U({url:o,body:e,signal:t,onEvent:s}){var l;const a=y(),n=await fetch(o,{method:"POST",headers:{"Content-Type":"application/json",Accept:"text/event-stream","X-CSRF":(l=a.system)==null?void 0:l.csrf,"X-Language":a.language.code},body:JSON.stringify(e),credentials:"same-origin",signal:t});if(!n.ok){let r=a.t("seo.ai.error.request");try{const c=await n.json();r=(c==null?void 0:c.message)||r}catch{}throw new Error(r)}if(!n.body)throw new Error(a.t("seo.ai.error.request"));await q(n.body.getReader(),r=>{var c;if(r.type==="error")throw new Error(((c=r.payload)==null?void 0:c.message)||a.t("seo.ai.error.request"));s(r)})}function B(o){const e=y();e.dialog.open({component:"k-form-dialog",props:{fields:{instructions:{label:e.t("seo.ai.dialog.custom.label"),type:"textarea",buttons:!1,placeholder:e.t("seo.ai.dialog.custom.placeholder"),required:!0}},submitButton:e.t("seo.ai.dialog.custom.submit")},on:{submit:t=>{e.dialog.close(),o(t)}}})}function F(o){var a;const t=(a=y().urls)==null?void 0:a.api,s=o==null?void 0:o.field;return!t||!s?null:`${t}/${s}/ai/stream`.replace(/([^:]\/)\/+/g,"$1")}function w(o,e,t,s,a,n,l,r){var c=typeof o=="function"?o.options:o;return e&&(c.render=e,c.staticRenderFns=t,c._compiled=!0),{exports:o,options:c}}const Z={__name:"alt-text",props:{ai:Boolean,autogenerate:Boolean,disabled:Boolean,endpoints:Object,id:String,label:String,help:String,name:String,placeholder:String,required:Boolean,value:{type:Object,default:()=>({text:"",decorative:!1,source:"manual"})}},emits:["input"],setup(o,{emit:e}){const t=o,s=y(),a=V(),n=g(null),l=g(!1);let r=null,c="";const m=v(()=>{var p;return((p=t.value)==null?void 0:p.text)??""}),u=v(()=>{var p;return((p=t.value)==null?void 0:p.decorative)??!1}),d=v(()=>{var p;return((p=t.value)==null?void 0:p.source)??"manual"}),b=v(()=>F(t.endpoints));async function _(p={}){const h=b.value;if(!(!h||t.disabled||l.value)){c="",k({text:"",source:"reviewed"}),r=new AbortController,l.value=!0;try{await U({url:h,body:p,signal:r.signal,onEvent:f=>{f.type==="text-delta"&&(c+=f.text||"",k({text:c,source:"reviewed"}))}})}catch(f){if((f==null?void 0:f.name)==="AbortError")return;console.error(f),s.notification.error((f==null?void 0:f.message)||s.t("seo.ai.error.request"))}finally{r=null,l.value=!1}}}function x(){r&&(r.abort(),r=null),l.value=!1}const M=v(()=>{if(l.value)return[{icon:"loader",text:s.t("seo.ai.action.stop"),theme:"red",click:()=>x()}];const p=[{icon:m.value===""?"seo-ai":"refresh",text:m.value===""?s.t("seo.ai.action.generate"):s.t("seo.ai.action.regenerate"),disabled:t.disabled||u.value||!b.value,click:()=>_()}];return m.value!==""&&p.push({icon:"cog",title:s.t("seo.ai.action.customize"),disabled:t.disabled||u.value||!b.value,click:()=>B(h=>{_({instructions:h.instructions})})}),p});function k(p){e("input",{text:m.value,decorative:u.value,source:d.value,...p})}function C(p){const h=d.value==="ai"||d.value==="reviewed"?"reviewed":"manual";k({text:p,source:h})}function S(p){var f;if(p.inputType==="insertLineBreak"||p.inputType==="insertParagraph"){p.preventDefault();return}const h=p.data??((f=p.dataTransfer)==null?void 0:f.getData("text/plain"));if(h&&/\n/.test(h)){p.preventDefault();const $=p.target,R=h.replace(/[\r\n]+/g," "),je=$.selectionStart,We=$.selectionEnd;$.setRangeText(R,je,We,"end"),$.dispatchEvent(new Event("input",{bubbles:!0}))}}return E(m,()=>{l.value||P(()=>a.autosize.update(n.value))}),T(()=>{P(()=>a.autosize(n.value))}),H(()=>{a.autosize.destroy(n.value),x()}),{__sfc:!0,props:t,$emit:e,panel:s,library:a,input:n,streaming:l,controller:r,streamedText:c,text:m,isDecorative:u,source:d,aiEndpointUrl:b,startAiStream:_,abortAiStream:x,buttons:M,emit:k,onTextInput:C,onBeforeInput:S}}};var j=function(){var e=this,t=e._self._c,s=e._self._setupProxy;return t("k-field",e._b({class:["k-alt-text-field",{"is-decorative":s.isDecorative}],attrs:{input:e.id},scopedSlots:e._u([e.ai&&!e.disabled?{key:"options",fn:function(){return[t("k-button-group",{staticClass:"k-field-options",attrs:{buttons:s.buttons,layout:"collapsed",size:"xs",variant:"filled"}})]},proxy:!0}:null],null,!0)},"k-field",e.$props,!1),[t("k-input",{attrs:{icon:!1,disabled:e.disabled}},[t("div",{staticClass:"k-alt-text-header"},[t("k-button",{staticClass:"k-alt-text-toggle",attrs:{disabled:e.disabled,icon:s.isDecorative?"toggle-off":"toggle-on",theme:s.isDecorative?null:"positive-icon",title:s.panel.t(s.isDecorative?"seo.altText.decorative.on":"seo.altText.decorative.off"),variant:"filled"},on:{click:function(a){return s.emit({decorative:!s.isDecorative})}}},[s.isDecorative?[e._v(" "+e._s(s.panel.t("seo.altText.decorative.on"))+" ")]:e._e()],2),t("textarea",{ref:"input",staticClass:"k-textarea-input-native",attrs:{id:e.id,disabled:e.disabled||s.isDecorative,placeholder:s.isDecorative?"":e.placeholder,rows:"1"},domProps:{value:s.text},on:{input:function(a){return s.onTextInput(a.target.value)},beforeinput:s.onBeforeInput}})],1)])],1)},W=[],G=w(Z,j,W);const K=G.exports,Y={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(){return F(this.endpoints)}},beforeDestroy(){this.abortAiStream()},methods:{async startAiStream(o={}){var a;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{await U({url:e,body:{instructions:o.instructions,edit:o.edit},signal:s.signal,onEvent:n=>{n.type==="text-delta"&&this.applyAiDelta(n.text||"")}})}catch(n){if((n==null?void 0:n.name)==="AbortError")return;console.error(n),this.$panel.notification.error((n==null?void 0:n.message)||this.$t("seo.ai.error.request"))}finally{this.aiAbortController=null,this.aiStreaming=!1}},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),l=t.tr.insert(a,n);s.dispatch(l)},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(){B(o=>{this.startAiStream({instructions:o.instructions})})}}};var J=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)},X=[],Q=w(Y,J,X);const ee=Q.exports,te={extends:"k-writer-input",methods:{createNodes(){return Vue.component("k-writer-input").options.methods.createNodes.call(this).filter(e=>e.name!=="hardBreak")}}};var se=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)},ae=[],oe=w(te,se,ae);const ne=oe.exports,re={__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=g({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=g(!1),l=g(null),r=v(()=>{const u=new URL(t.pageUrl);for(const d of a)s.value[d.key]&&u.searchParams.set(d.key,s.value[d.key]);return u.toString()}),c=async()=>{try{await navigator.clipboard.writeText(r.value),n.value=!0,setTimeout(()=>{n.value=!1},2e3)}catch(u){console.error("Failed to copy:",u)}};E(r,()=>{P(()=>{l.value&&(l.value.scrollLeft=l.value.scrollWidth)})});const m=u=>{var d;t.visible&&(u.ctrlKey||u.metaKey)&&u.key==="c"&&!((d=window.getSelection())!=null&&d.toString())&&(u.preventDefault(),c())};return T(()=>{document.addEventListener("keydown",m)}),L(()=>{document.removeEventListener("keydown",m)}),{__sfc:!0,props:t,emit:e,params:s,fields:a,copied:n,urlInput:l,generatedUrl:r,copyToClipboard:c,handleKeydown:m}}};var ie=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)},le=[],ce=w(re,ie,le);const ue=ce.exports,pe={__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=(r={})=>{window.panel.drawer.refresh({query:{metric:r.metric??t.metric,asc:r.asc??t.sortAsc?1:0,page:r.page??t.page}})};return{__sfc:!0,props:t,emit:e,pagination:s,reload:a,handlePaginate:r=>a({page:r.page}),handleHeader:({columnIndex:r})=>{const c=t.metric===r?!t.sortAsc:r==="position"||r==="query";a({metric:r,asc:c,page:1})}}}};var de=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:l}){return[t("span",[e._v(" "+e._s(l)+" "),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)},_e=[],me=w(pe,de,_e);const ve=me.exports,z=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:l}=s.selection,r=t.create({variable:e.variable}),c=s.tr;c.delete(n,l),c.insert(n,r),c.insertText(" ",n+r.nodeSize);const m=s.selection.constructor,u=n+r.nodeSize+1;return c.setSelection(m.near(c.doc.resolve(u))),a(c.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(l){var r,c;return s.dataset.seoTemplateVariable=l.attrs.variable,s.textContent=(c=(r=window.panel)==null?void 0:r.$t)==null?void 0:c.call(r,e.label),!0},ignoreMutation:()=>!0}}}},D={blueprint:String,lock:[Boolean,Object],help:String,name:String,parent:String,timestamp:Number},fe={__name:"heading-structure",props:D,setup(o){const e=o,t=y(),{load:s}=I(),a=g(null),n=v(()=>{var u;return(u=a.value)==null?void 0:u.some((d,b)=>{var _;return d.level>(((_=a.value[b-1])==null?void 0:_.level)??0)+1})}),l=v(()=>{var u;return((u=a.value)==null?void 0:u.filter(d=>d.level===1).length)>1}),r=v(()=>{var u;return((u=a.value)==null?void 0:u.filter(d=>d.level===1).length)===0}),c=()=>s({parent:e.parent,name:e.name}).then(u=>{a.value=u.data}),m=(u,d)=>{var b;return!!(u.level>(((b=a.value[d-1])==null?void 0:b.level)??0)+1||u.level===1&&a.value[d-1]||u.level===1&&a.value.filter(_=>_.level===1).length>1)};return T(()=>{c(),t.events.on("content.save",u=>{c()})}),L(()=>t.events.off("content.save")),{__sfc:!0,props:e,panel:t,load:s,data:a,incorrectOrder:n,multipleH1:l,noH1:r,handleLoad:c,itemInvalid:m}}};var ge=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()},he=[],ke=w(fe,ge,he);const be=ke.exports,we={__name:"facebook-preview",props:{ogTitle:String,url:String,ogDescription:String,ogImage:String},setup(o){const e=o,t=v(()=>new window.URL(e.url).host);return{__sfc:!0,props:e,host:t}}};var ye=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=[],Se=w(we,ye,Ce);const $e=Se.exports,xe={__name:"google-preview",props:{title:String,url:String,description:String,ogSiteName:String},setup(o){const e=o,t=v(()=>new window.URL(e.url).origin),s=v(()=>new window.URL(e.url).pathname),a=v(()=>new window.URL(e.url).hostname),n=v(()=>{const l=s.value;if(!l||l==="/")return"";const r=l.split("/").filter(Boolean);return r.length===0?"":r.length===1?` › ${r[0]}`:` › … › ${r[r.length-1]}`});return{__sfc:!0,props:e,origin:t,pathname:s,domain:a,breadcrumbs:n}}};var Te=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()])},Ee=[],Pe=w(xe,Te,Ee);const Le=Pe.exports,De={__name:"slack-preview",props:{ogTitle:String,ogSiteName:String,ogDescription:String,ogImage:String,url:String},setup(o){const e=o,t=v(()=>new window.URL(e.url).origin),s=v(()=>new window.URL(e.url).hostname),a=g(!0);return{__sfc:!0,props:e,origin:t,domain:s,showImage:a}}};var Re=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()])},Ae=[],Ne=w(De,Re,Ae);const Ie=Ne.exports,Oe={__name:"seo-preview",props:D,setup(o){const e=o,t=y(),s=N(),{load:a}=I(),n=g(null),l=g([]),r=v(()=>e.parent==="site"),c=v(()=>e.label||t.t("seo.sections.preview.title")),m=v(()=>{var x;const _=(x=n.value)==null?void 0:x.pageTitle;return r.value&&_?t.t("seo.sections.preview.titleWithPage",{title:_}):c.value}),u=g(window.localStorage.getItem("kSEOPreviewType")??"google");E(u,_=>{window.localStorage.setItem("kSEOPreviewType",_)});const d=()=>{a({parent:e.parent,name:e.name}).then(_=>{n.value=_.meta,l.value=_.options,!window.localStorage.getItem("kSEOPreviewType")&&_.options.length>0&&(u.value=_.options[0].value)})},b=()=>{var _;(_=n.value)!=null&&_.panelUrl&&s.$go(n.value.panelUrl)};return T(()=>{d(),t.events.on("content.save",_=>{d()})}),L(()=>t.events.off("content.save")),{__sfc:!0,props:e,panel:t,app:s,load:a,meta:n,options:l,isSiteParent:r,baseLabel:c,headerLabel:m,type:u,handleLoad:d,openPanelTarget:b,FacebookPreview:$e,GooglePreview:Le,SlackPreview:Ie}}};var Ue=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()},Be=[],Fe=w(Oe,Ue,Be);const ze=Fe.exports,Me={__name:"search-console",props:D,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=A(),n=g(null),l=g([]),r=g("clicks"),c=g(null),m=g("clicks"),u=[{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")}],d=async()=>{const k=await a.get(`${e.parent}/sections/${e.name}`,{metric:m.value,limit:10});n.value=k.status,l.value=k.data??[],r.value=m.value};return E(m,()=>d()),T(()=>{d(),s.events.on("gsc.propertySelected",()=>{d()})}),{__sfc:!0,MESSAGES:t,props:e,panel:s,api:a,status:n,data:l,displayMetric:r,dropdown:c,metric:m,metricOptions:u,handleLoad:d,getBarWidth:k=>{if(!l.value.length)return 0;const C=r.value,S=l.value.map(R=>R[C]),p=Math.min(...S),h=Math.max(...S),f=k[C];if(h===p)return 100;let $;return C==="position"?$=(h-f)/(h-p):$=(f-p)/(h-p),10+$*90},formatValue:k=>{const C=r.value,S=k[C],p=s.translation.code;return C==="ctr"?new Intl.NumberFormat(p,{style:"percent",minimumFractionDigits:1,maximumFractionDigits:1}).format(S):C==="position"?new Intl.NumberFormat(p,{minimumFractionDigits:1,maximumFractionDigits:1}).format(S):new Intl.NumberFormat(p).format(S)},handleConnect:()=>{const k=encodeURIComponent(window.location.href);window.location.href=`/__seo/gsc/auth?return=${k}`},handleSelectProperty:()=>s.dialog.open("seo/gsc/select-property")}}};var Ve=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()},He=[],qe=w(Me,Ve,He);const Ze=qe.exports;panel.plugin("tobimori/seo",{icons:{"seo-ai":'<path d="M16.4356 3.21188C16.8261 2.82185 17.4592 2.82157 17.8496 3.21188L20.6777 6.04099C21.0681 6.43152 21.0682 7.06457 20.6777 7.45505L7.2422 20.8896H3.00001V16.6475L16.4356 3.21188ZM5.00001 17.4756V18.8896H6.41407L15.7276 9.57615L14.3135 8.16208L5.00001 17.4756ZM4.5293 1.3193C4.70583 0.893505 5.29418 0.893508 5.47071 1.3193L5.72364 1.93063C6.15555 2.97342 6.96155 3.80613 7.97462 4.2568L8.69239 4.57614C9.10267 4.75896 9.10262 5.35616 8.69239 5.53903L7.93263 5.87692C6.94497 6.3162 6.15339 7.11943 5.71387 8.1279L5.4668 8.69334C5.28636 9.10747 4.71366 9.10747 4.53321 8.69334L4.28614 8.1279C3.84661 7.11943 3.05506 6.3162 2.06739 5.87692L1.30762 5.53903C0.897483 5.35617 0.897435 4.75896 1.30762 4.57614L2.0254 4.2568C3.03845 3.80614 3.84446 2.97344 4.27637 1.93063L4.5293 1.3193ZM15.7276 6.74802L17.1426 8.16208L18.5567 6.74802L17.1426 5.33395L15.7276 6.74802Z" />',robots:'<path d="M13.5 2c0 .444-.193.843-.5 1.118V5h5a3 3 0 0 1 3 3v10a3 3 0 0 1-3 3H6a3 3 0 0 1-3-3V8a3 3 0 0 1 3-3h5V3.118A1.5 1.5 0 1 1 13.5 2ZM6 7a1 1 0 0 0-1 1v10a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1V8a1 1 0 0 0-1-1H6Zm-4 3H0v6h2v-6Zm20 0h2v6h-2v-6ZM9 14.5a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Zm6 0a1.5 1.5 0 1 0 0-3 1.5 1.5 0 0 0 0 3Z" />',"robots-off":'<path fill-rule="evenodd" clip-rule="evenodd" d="M21 16.786V8a3 3 0 0 0-3-3h-5V3.118a1.5 1.5 0 1 0-2 0V5H9.214l2 2H18a1 1 0 0 1 1 1v6.786l2 2ZM2.093 3.507l2.099 2.099A2.995 2.995 0 0 0 3 8v10a3 3 0 0 0 3 3h12c.463 0 .902-.105 1.293-.292l1.9 1.9 1.414-1.415-6.88-6.88a1.5 1.5 0 1 0-2.04-2.04L3.508 2.093 2.093 3.507ZM5 8a1 1 0 0 1 .65-.937L17.585 19H6a1 1 0 0 1-1-1V8Zm-5 2h2v6H0v-6Zm24 0h-2v6h2v-6Zm-13.5 3a1.5 1.5 0 1 1-3 0 1.5 1.5 0 0 1 3 0Z" />'},sections:{"heading-structure":be,"seo-preview":ze,"seo-search-console":Ze},fields:{"alt-text":K,"seo-writer":ee},components:{"k-seo-writer-input":ne,"k-seo-utm-share-dialog":ue,"k-gsc-drawer":ve},writerNodes:{seoTemplateTitle:z({name:"seoTemplateTitle",icon:"page",variable:"title",label:"seo.writerNodes.template.title",theme:"blue"}),seoTemplateSiteTitle:z({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..e77154f --- /dev/null +++ b/site/plugins/kirby-seo/index.php @@ -0,0 +1,100 @@ +<?php + +@include_once __DIR__ . '/vendor/autoload.php'; + +use Kirby\Cms\App; +use Kirby\Data\Json; +use Spatie\SchemaOrg\Schema; +use Kirby\Toolkit\A; +use Kirby\Filesystem\Dir; +use Kirby\Filesystem\F; +use tobimori\Seo\AltText; + +if ( + version_compare(App::version() ?? '0.0.0', '5.0.0', '<') === true || + version_compare(App::version() ?? '0.0.0', '6.0.0', '>=') === 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', + 'fieldMethods' => [ + 'toAltText' => fn ($field) => AltText::fromField($field), + ], + '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/prompts/tasks/alt-text' => __DIR__ . '/snippets/prompts/tasks/alt-text.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/lefthook.yml b/site/plugins/kirby-seo/lefthook.yml new file mode 100644 index 0000000..5b491b6 --- /dev/null +++ b/site/plugins/kirby-seo/lefthook.yml @@ -0,0 +1,21 @@ +pre-commit: + piped: true + commands: + build: + priority: 1 + run: pnpm run build && git add index.css index.js + eslint: + priority: 2 + glob: "src/*.{js,vue}" + run: pnpm exec eslint --fix {staged_files} + stage_fixed: true + format: + priority: 2 + glob: "src/*.{js,vue}" + run: pnpm exec oxfmt --no-error-on-unmatched-pattern {staged_files} + stage_fixed: true + php-cs-fixer: + priority: 2 + glob: "*.php" + run: PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --config=.php-cs-fixer.dist.php {staged_files} + stage_fixed: true 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 @@ +<?php + +/** + * @var \Kirby\Cms\Page $page + */ + +use Kirby\Cms\Html; + +$tags = $page->metadata()->snippetData(); + +// if we're using slots, the user wants to output priority tags such as <title> +// 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/alt-text.php b/site/plugins/kirby-seo/snippets/prompts/tasks/alt-text.php new file mode 100644 index 0000000..2407549 --- /dev/null +++ b/site/plugins/kirby-seo/snippets/prompts/tasks/alt-text.php @@ -0,0 +1,52 @@ +<?php + +/** @var \Kirby\Cms\File $file + ** @var \Kirby\Cms\Site $site + ** @var string|null $instructions + ** @var array<string>|null $languages */ ?> + +<role> + You are an accessibility expert writing alt text for images on <?= $site->title() ?>. +</role> + +<rules> + - Be brief. One short sentence is ideal. Two sentences maximum, only if truly needed. + - Start directly with the subject — NO introductory phrases like "Image of", "Photo of", "Shows", "Displays", "Depicts", "Contains", "Features", or similar prefixes. + - Describe the meaning and purpose, not visual details. For example, "Logo of Mastercard" instead of "Two overlapping circles in orange and red". + - DO NOT enumerate individual UI elements, icons, colors, or positions. Focus on the overall subject. + - Do not add a trailing period to short noun phrases. Only use periods for full sentences. + - NEVER output any formatting. No HTML tags, no quotes, no markdown. +<?php if (!empty($languages)) : ?> + - Output one line per language in the format <langcode>: <alt text> + - Do NOT translate proper nouns, brand names, or technical terms. + - Output ONLY the language lines. No additional text. +<?php else : ?> + - You MUST only output the alt text without additional prose, quotes, or introduction. + - The output language MUST be <language><?= $site->lang() ?></language>. +<?php endif ?> +</rules> + +<?php if (isset($instructions) && $instructions !== null && $instructions !== '') : ?> +<user-instructions> + <?= $instructions ?> +</user-instructions> +<?php endif ?> + +<task> + Write descriptive alt text for the attached image. + + The file is named <filename><?= $file->filename() ?></filename>. + + <?php if ($file->parent() instanceof \Kirby\Cms\Page) : ?> + The image is on a page called <page-title><?= $file->parent()->title() ?></page-title>. + <?php endif ?> + + <?php if ($file->template()) : ?> + This image uses the file template <template><?= $file->template() ?></template>. + <?php endif ?> + +<?php if (!empty($languages)) : ?> + Output alt text in these languages: <?= implode(', ', $languages) ?> + +<?php endif ?> +</task> 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..a397c1a --- /dev/null +++ b/site/plugins/kirby-seo/templates/sitemap.xsl.php @@ -0,0 +1,256 @@ +<?= '<?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:xhtml="http://www.w3.org/1999/xhtml" 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 + + Love & Kindness +

+
+ + + + + \ 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..a3b9db3 --- /dev/null +++ b/site/plugins/kirby-seo/translations/cs.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "Trénování AI", + "fields.robots.ai.help": "Zda mohou poskytovatelé AI tuto stránku používat k trénování.", + "fields.robots.imageai.label": "Trénování AI na obrázcích", + "fields.robots.imageai.help": "Zda mohou poskytovatelé AI používat obrázky na této stránce k trénování.", + "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", + "altText.decorative.on": "Není potřeba popisek (pouze vizuální prvek)", + "altText.decorative.off": "Vyžaduje popisek" +} diff --git a/site/plugins/kirby-seo/translations/de.json b/site/plugins/kirby-seo/translations/de.json new file mode 100644 index 0000000..e518c23 --- /dev/null +++ b/site/plugins/kirby-seo/translations/de.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "KI-Training", + "fields.robots.ai.help": "Ob KI-Anbieter diese Seite für das Training verwenden dürfen.", + "fields.robots.imageai.label": "KI-Bildtraining", + "fields.robots.imageai.help": "Ob KI-Anbieter Bilder auf dieser Seite für das Training verwenden 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", + "altText.decorative.on": "Keine Beschreibung nötig (rein dekorativ)", + "altText.decorative.off": "Beschreibung erforderlich" +} diff --git a/site/plugins/kirby-seo/translations/en.json b/site/plugins/kirby-seo/translations/en.json new file mode 100644 index 0000000..f28d8ba --- /dev/null +++ b/site/plugins/kirby-seo/translations/en.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "AI Training", + "fields.robots.ai.help": "Whether AI providers may use this page for training.", + "fields.robots.imageai.label": "AI Image Training", + "fields.robots.imageai.help": "Whether AI providers may use images on this page for training.", + "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", + "altText.decorative.on": "No description needed (purely visual)", + "altText.decorative.off": "Needs description" +} diff --git a/site/plugins/kirby-seo/translations/fr.json b/site/plugins/kirby-seo/translations/fr.json new file mode 100644 index 0000000..70786d9 --- /dev/null +++ b/site/plugins/kirby-seo/translations/fr.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "Entraînement IA", + "fields.robots.ai.help": "Indique si les fournisseurs d'IA peuvent utiliser cette page pour l'entraînement.", + "fields.robots.imageai.label": "Entraînement IA des images", + "fields.robots.imageai.help": "Indique si les fournisseurs d'IA peuvent utiliser les images de cette page pour l'entraînement.", + "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", + "altText.decorative.on": "Aucune description requise (purement visuel)", + "altText.decorative.off": "Nécessite une description" +} diff --git a/site/plugins/kirby-seo/translations/nl.json b/site/plugins/kirby-seo/translations/nl.json new file mode 100644 index 0000000..f446d46 --- /dev/null +++ b/site/plugins/kirby-seo/translations/nl.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "AI-training", + "fields.robots.ai.help": "Of AI-aanbieders deze pagina mogen gebruiken voor training.", + "fields.robots.imageai.label": "AI-beeldtraining", + "fields.robots.imageai.help": "Of AI-aanbieders afbeeldingen op deze pagina mogen gebruiken voor training.", + "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", + "altText.decorative.on": "Geen beschrijving nodig (alleen decoratief)", + "altText.decorative.off": "Beschrijving vereist" +} 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..3be3bff --- /dev/null +++ b/site/plugins/kirby-seo/translations/pt_PT.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "Treino de IA", + "fields.robots.ai.help": "Se os fornecedores de IA podem usar esta página para treino.", + "fields.robots.imageai.label": "Treino de IA de imagens", + "fields.robots.imageai.help": "Se os fornecedores de IA podem usar imagens desta página para treino.", + "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", + "altText.decorative.on": "Não precisa de descrição (é só visual)", + "altText.decorative.off": "Precisa de descrição" +} diff --git a/site/plugins/kirby-seo/translations/ro.json b/site/plugins/kirby-seo/translations/ro.json new file mode 100644 index 0000000..644f125 --- /dev/null +++ b/site/plugins/kirby-seo/translations/ro.json @@ -0,0 +1,123 @@ +{ + "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ă.", + "fields.robots.ai.label": "Antrenare AI", + "fields.robots.ai.help": "Dacă se permite furnizorilor de AI să utilizeze această pagină pentru antrenare.", + "fields.robots.imageai.label": "Antrenare AI imagini", + "fields.robots.imageai.help": "Dacă se permite furnizorilor de AI să utilizeze imaginile de pe această pagină pentru antrenare.", + "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", + "altText.decorative.on": "Nu este necesară nicio descriere (doar element vizual)", + "altText.decorative.off": "Are nevoie de descriere" +} 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..52b5723 --- /dev/null +++ b/site/plugins/kirby-seo/translations/sv_SE.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "AI-träning", + "fields.robots.ai.help": "Om AI-leverantörer får använda den här sidan för träning.", + "fields.robots.imageai.label": "AI-bildträning", + "fields.robots.imageai.help": "Om AI-leverantörer får använda bilder på den här sidan för träning.", + "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", + "altText.decorative.on": "Ingen beskrivning behövs (endast dekorativt)", + "altText.decorative.off": "Behöver beskrivning" +} diff --git a/site/plugins/kirby-seo/translations/tr.json b/site/plugins/kirby-seo/translations/tr.json new file mode 100644 index 0000000..608887a --- /dev/null +++ b/site/plugins/kirby-seo/translations/tr.json @@ -0,0 +1,123 @@ +{ + "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.", + "fields.robots.ai.label": "Yapay Zeka Eğitimi", + "fields.robots.ai.help": "Yapay zeka sağlayıcılarının bu sayfayı eğitim için kullanıp kullanamayacağını belirtir.", + "fields.robots.imageai.label": "Yapay Zeka Görsel Eğitimi", + "fields.robots.imageai.help": "Yapay zeka sağlayıcılarının bu sayfadaki görselleri eğitim için kullanıp kullanamayacağını 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ç", + "altText.decorative.on": "Açıklama gerekmez (sadece görsel amaçlı)", + "altText.decorative.off": "Açıklama gerekli" +} diff --git a/site/snippets/footer.php b/site/snippets/footer.php index 308b1d0..1f2fa6b 100644 --- a/site/snippets/footer.php +++ b/site/snippets/footer.php @@ -1,2 +1,3 @@ + diff --git a/site/snippets/header.php b/site/snippets/header.php index 7af780d..9a8e73c 100644 --- a/site/snippets/header.php +++ b/site/snippets/header.php @@ -4,21 +4,11 @@ - <?= $site->title() ?> - <?= $page->title() ?> - + - - - - - - cover()->toFile()): ?> - - - diff --git a/vendor/composer/autoload_classmap.php b/vendor/composer/autoload_classmap.php index 196546b..f4534ae 100644 --- a/vendor/composer/autoload_classmap.php +++ b/vendor/composer/autoload_classmap.php @@ -500,4 +500,26 @@ return array( 'Whoops\\Util\\SystemFacade' => $vendorDir . '/filp/whoops/src/Whoops/Util/SystemFacade.php', 'Whoops\\Util\\TemplateHelper' => $vendorDir . '/filp/whoops/src/Whoops/Util/TemplateHelper.php', 'claviska\\SimpleImage' => $vendorDir . '/claviska/simpleimage/src/claviska/SimpleImage.php', + 'tobimori\\Seo\\Ai' => $baseDir . '/site/plugins/kirby-seo/classes/Ai.php', + 'tobimori\\Seo\\Ai\\Chunk' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/Chunk.php', + 'tobimori\\Seo\\Ai\\Content' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/Content.php', + 'tobimori\\Seo\\Ai\\Driver' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/Driver.php', + 'tobimori\\Seo\\Ai\\Drivers\\Anthropic' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/Drivers/Anthropic.php', + 'tobimori\\Seo\\Ai\\Drivers\\Gemini' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/Drivers/Gemini.php', + 'tobimori\\Seo\\Ai\\Drivers\\OpenAi' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/Drivers/OpenAi.php', + 'tobimori\\Seo\\Ai\\SseStream' => $baseDir . '/site/plugins/kirby-seo/classes/Ai/SseStream.php', + 'tobimori\\Seo\\AltText' => $baseDir . '/site/plugins/kirby-seo/classes/AltText.php', + 'tobimori\\Seo\\Buttons\\RobotsViewButton' => $baseDir . '/site/plugins/kirby-seo/classes/Buttons/RobotsViewButton.php', + 'tobimori\\Seo\\Buttons\\UtmShareViewButton' => $baseDir . '/site/plugins/kirby-seo/classes/Buttons/UtmShareViewButton.php', + 'tobimori\\Seo\\Dialogs\\UtmShareDialog' => $baseDir . '/site/plugins/kirby-seo/classes/Dialogs/UtmShareDialog.php', + 'tobimori\\Seo\\Field\\AltTextField' => $baseDir . '/site/plugins/kirby-seo/classes/Field/AltTextField.php', + 'tobimori\\Seo\\GoogleSearchConsole' => $baseDir . '/site/plugins/kirby-seo/classes/GoogleSearchConsole.php', + 'tobimori\\Seo\\IndexNow' => $baseDir . '/site/plugins/kirby-seo/classes/IndexNow.php', + 'tobimori\\Seo\\Jobs\\GenerateAltTextJob' => $baseDir . '/site/plugins/kirby-seo/classes/Jobs/GenerateAltTextJob.php', + 'tobimori\\Seo\\Meta' => $baseDir . '/site/plugins/kirby-seo/classes/Meta.php', + 'tobimori\\Seo\\SchemaSingleton' => $baseDir . '/site/plugins/kirby-seo/classes/SchemaSingleton.php', + 'tobimori\\Seo\\Seo' => $baseDir . '/site/plugins/kirby-seo/classes/Seo.php', + 'tobimori\\Seo\\Sitemap\\Sitemap' => $baseDir . '/site/plugins/kirby-seo/classes/Sitemap/Sitemap.php', + 'tobimori\\Seo\\Sitemap\\SitemapIndex' => $baseDir . '/site/plugins/kirby-seo/classes/Sitemap/SitemapIndex.php', + 'tobimori\\Seo\\Sitemap\\SitemapUrl' => $baseDir . '/site/plugins/kirby-seo/classes/Sitemap/SitemapUrl.php', ); diff --git a/vendor/composer/autoload_psr4.php b/vendor/composer/autoload_psr4.php index c9abc16..422005f 100644 --- a/vendor/composer/autoload_psr4.php +++ b/vendor/composer/autoload_psr4.php @@ -6,6 +6,7 @@ $vendorDir = dirname(__DIR__); $baseDir = dirname($vendorDir); return array( + 'tobimori\\Seo\\' => array($baseDir . '/site/plugins/kirby-seo/classes'), 'Whoops\\' => array($vendorDir . '/filp/whoops/src/Whoops'), 'Symfony\\Polyfill\\Mbstring\\' => array($vendorDir . '/symfony/polyfill-mbstring'), 'Symfony\\Polyfill\\Intl\\Normalizer\\' => array($vendorDir . '/symfony/polyfill-intl-normalizer'), diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php index 3280b5b..cbb8adf 100644 --- a/vendor/composer/autoload_static.php +++ b/vendor/composer/autoload_static.php @@ -17,6 +17,10 @@ class ComposerStaticInitda1c3a8eb3e9e3b252ad405f32a3f585 ); public static $prefixLengthsPsr4 = array ( + 't' => + array ( + 'tobimori\\Seo\\' => 13, + ), 'W' => array ( 'Whoops\\' => 7, @@ -54,6 +58,10 @@ class ComposerStaticInitda1c3a8eb3e9e3b252ad405f32a3f585 ); public static $prefixDirsPsr4 = array ( + 'tobimori\\Seo\\' => + array ( + 0 => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes', + ), 'Whoops\\' => array ( 0 => __DIR__ . '/..' . '/filp/whoops/src/Whoops', @@ -621,6 +629,28 @@ class ComposerStaticInitda1c3a8eb3e9e3b252ad405f32a3f585 'Whoops\\Util\\SystemFacade' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Util/SystemFacade.php', 'Whoops\\Util\\TemplateHelper' => __DIR__ . '/..' . '/filp/whoops/src/Whoops/Util/TemplateHelper.php', 'claviska\\SimpleImage' => __DIR__ . '/..' . '/claviska/simpleimage/src/claviska/SimpleImage.php', + 'tobimori\\Seo\\Ai' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai.php', + 'tobimori\\Seo\\Ai\\Chunk' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/Chunk.php', + 'tobimori\\Seo\\Ai\\Content' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/Content.php', + 'tobimori\\Seo\\Ai\\Driver' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/Driver.php', + 'tobimori\\Seo\\Ai\\Drivers\\Anthropic' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/Drivers/Anthropic.php', + 'tobimori\\Seo\\Ai\\Drivers\\Gemini' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/Drivers/Gemini.php', + 'tobimori\\Seo\\Ai\\Drivers\\OpenAi' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/Drivers/OpenAi.php', + 'tobimori\\Seo\\Ai\\SseStream' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Ai/SseStream.php', + 'tobimori\\Seo\\AltText' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/AltText.php', + 'tobimori\\Seo\\Buttons\\RobotsViewButton' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Buttons/RobotsViewButton.php', + 'tobimori\\Seo\\Buttons\\UtmShareViewButton' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Buttons/UtmShareViewButton.php', + 'tobimori\\Seo\\Dialogs\\UtmShareDialog' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Dialogs/UtmShareDialog.php', + 'tobimori\\Seo\\Field\\AltTextField' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Field/AltTextField.php', + 'tobimori\\Seo\\GoogleSearchConsole' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/GoogleSearchConsole.php', + 'tobimori\\Seo\\IndexNow' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/IndexNow.php', + 'tobimori\\Seo\\Jobs\\GenerateAltTextJob' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Jobs/GenerateAltTextJob.php', + 'tobimori\\Seo\\Meta' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Meta.php', + 'tobimori\\Seo\\SchemaSingleton' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/SchemaSingleton.php', + 'tobimori\\Seo\\Seo' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Seo.php', + 'tobimori\\Seo\\Sitemap\\Sitemap' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Sitemap/Sitemap.php', + 'tobimori\\Seo\\Sitemap\\SitemapIndex' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Sitemap/SitemapIndex.php', + 'tobimori\\Seo\\Sitemap\\SitemapUrl' => __DIR__ . '/../..' . '/site/plugins/kirby-seo/classes/Sitemap/SitemapUrl.php', ); public static function getInitializer(ClassLoader $loader) diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index 429cd87..97bd154 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -1289,6 +1289,77 @@ } ], "install-path": "../symfony/yaml" + }, + { + "name": "tobimori/kirby-seo", + "version": "2.0.0-beta.3", + "version_normalized": "2.0.0.0-beta3", + "source": { + "type": "git", + "url": "https://github.com/tobimori/kirby-seo.git", + "reference": "c16472022f53eba9c58ec73b10926129f889f86d" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/tobimori/kirby-seo/zipball/c16472022f53eba9c58ec73b10926129f889f86d", + "reference": "c16472022f53eba9c58ec73b10926129f889f86d", + "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": { + "ext-imagick": "Rasterize non-resizable images (SVG, etc.) for AI alt text generation", + "getkirby/cli": "Enable background processing support", + "spatie/schema-org": "Enable the Schema.org support", + "tobimori/kirby-queues": "Enable background processing support" + }, + "time": "2026-03-10T23:31:27+00:00", + "type": "kirby-plugin", + "extra": { + "kirby-cms-path": false + }, + "installation-source": "dist", + "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-beta.3" + }, + "funding": [ + { + "url": "https://plugins.andkindness.com/seo/preorder", + "type": "custom" + }, + { + "url": "https://github.com/tobimori", + "type": "github" + } + ], + "install-path": "../../site/plugins/kirby-seo" } ], "dev": true, diff --git a/vendor/composer/installed.php b/vendor/composer/installed.php index 11103c6..110f01e 100644 --- a/vendor/composer/installed.php +++ b/vendor/composer/installed.php @@ -3,7 +3,7 @@ 'name' => 'getkirby/plainkit', 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '3cafcf3167251bbbfd64183de5da67c4a488fa7d', + 'reference' => 'baab2fb3a185748e0bcff713054202f27b550ac6', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -67,7 +67,7 @@ 'getkirby/plainkit' => array( 'pretty_version' => 'dev-main', 'version' => 'dev-main', - 'reference' => '3cafcf3167251bbbfd64183de5da67c4a488fa7d', + 'reference' => 'baab2fb3a185748e0bcff713054202f27b550ac6', 'type' => 'project', 'install_path' => __DIR__ . '/../../', 'aliases' => array(), @@ -193,5 +193,14 @@ 'aliases' => array(), 'dev_requirement' => false, ), + 'tobimori/kirby-seo' => array( + 'pretty_version' => '2.0.0-beta.3', + 'version' => '2.0.0.0-beta3', + 'reference' => 'c16472022f53eba9c58ec73b10926129f889f86d', + 'type' => 'kirby-plugin', + 'install_path' => __DIR__ . '/../../site/plugins/kirby-seo', + 'aliases' => array(), + 'dev_requirement' => false, + ), ), ); diff --git a/vendor/composer/platform_check.php b/vendor/composer/platform_check.php index d32d90c..2a8f1c8 100644 --- a/vendor/composer/platform_check.php +++ b/vendor/composer/platform_check.php @@ -4,8 +4,8 @@ $issues = array(); -if (!(PHP_VERSION_ID >= 80200)) { - $issues[] = 'Your Composer dependencies require a PHP version ">= 8.2.0". You are running ' . PHP_VERSION . '.'; +if (!(PHP_VERSION_ID >= 80300)) { + $issues[] = 'Your Composer dependencies require a PHP version ">= 8.3.0". You are running ' . PHP_VERSION . '.'; } if ($issues) {