Skip to content

Commit cd062dc

Browse files
committed
Release v2.0.0 compatible with Kirby 3
1 parent c4ce024 commit cd062dc

20 files changed

+2489
-45
lines changed

.editorconfig

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,3 @@ trim_trailing_whitespace = true
1010

1111
[*.md]
1212
trim_trailing_whitespace = false
13-
14-
[*.yml]
15-
indent_size = 2

.gitignore

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
1+
# OS files
12
.DS_Store
2-
*.cache
3-
vendor
3+
4+
# npm modules
5+
/node_modules
6+
7+
# files of Composer dependencies that are not needed for the plugin
8+
/vendor/**/.*
9+
/vendor/**/*.json
10+
/vendor/**/*.txt
11+
/vendor/**/*.md
12+
/vendor/**/*.yml
13+
/vendor/**/*.yaml
14+
/vendor/**/*.xml
15+
/vendor/**/*.dist
16+
/vendor/**/readme.php
17+
/vendor/**/LICENSE
18+
/vendor/**/COPYING
19+
/vendor/**/VERSION
20+
/vendor/**/docs/*
21+
/vendor/**/example/*
22+
/vendor/**/examples/*
23+
/vendor/**/test/*
24+
/vendor/**/tests/*
25+
/vendor/**/php4/*
26+
/vendor/getkirby/composer-installer

LICENSE.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) Pedro Borges
4+
5+
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:
6+
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8+
9+
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.

changelog.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1-
# Change Log
1+
# Changelog
22
All notable changes to this project will be documented in this file.
33

4+
## [2.0.0] - 2019-02-21
5+
This version adds support to Kirby 3. All options remain and work in the same way as they did in Kirby 2.
6+
7+
For Kirby 2, you can download the [plugin v1.1.1](https://github.com/pedroborges/kirby-meta-tags/archive/v1.1.1.zip) and install it manually in the `site/plugins/meta-tags`.
8+
49
## [1.1.1] - 2018-07-08
510
### Fixed
611
- When capitalizing the `@type` first letter, other capital letters in the word were being converted to lowercase. This has been fixed.

composer.json

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,27 @@
11
{
22
"name": "pedroborges/kirby-meta-tags",
3-
"description": "HTML meta tags generator for Kirby.",
4-
"version": "2.0.0-alpha-1",
5-
"keywords": ["kirby-plugin"],
3+
"description": "HTML meta tags generator for Kirby 3.",
4+
"keywords": ["kirby-plugin", "meta-tags", "open-graph", "twitter-cards", "json-ld"],
5+
"license": "MIT",
6+
"homepage": "https://github.com/pedroborges/kirby-meta-tags",
7+
"type": "kirby-plugin",
68
"authors": [
79
{
810
"name": "Pedro Borges",
911
"email": "[email protected]"
1012
}
1113
],
14+
"require": {
15+
"php": ">=7.1.0",
16+
"getkirby/composer-installer": "^1.1",
17+
"pedroborges/meta-tags": "^0.0.2"
18+
},
1219
"autoload": {
1320
"files": [
14-
"config.php"
21+
"helpers.php"
1522
],
1623
"psr-4": {
1724
"PedroBorges\\KirbyMetaTags\\": "src/"
1825
}
19-
},
20-
"require": {
21-
"php": ">=7.1.0",
22-
"pedroborges/meta-tags": "^0.0.2"
2326
}
2427
}

composer.lock

Lines changed: 42 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config.php renamed to helpers.php

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,7 @@
11
<?php
22

3-
use Kirby\Cms\Page;
43
use PedroBorges\KirbyMetaTags\MetaTags;
54

6-
Kirby::plugin('pedroborges/metatags', [
7-
'pageMethods' => [
8-
'metaTags' => function ($groups = null) {
9-
return metaTags($this)->render($groups);
10-
}
11-
]
12-
]);
13-
145
if (! function_exists('metaTags')) {
156
/**
167
* Generate meta tags for a given page.

index.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
11
<?php
22

3-
require_once __DIR__ . '/vendor/autoload.php';
3+
require_once __DIR__.'/vendor/autoload.php';
4+
5+
Kirby::plugin('pedroborges/meta-tags', [
6+
'pageMethods' => [
7+
'metaTags' => function ($groups = null) {
8+
return metaTags($this)->render($groups);
9+
}
10+
]
11+
]);

readme.md

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,19 @@ HTML meta tags generator for Kirby. Supports [Open Graph](http://ogp.me), [Twitt
99
## Installation
1010

1111
### Download
12-
[Download the files](https://github.com/pedroborges/kirby-meta-tags/releases/download/v2.0.0-alpha-1/meta-tags.zip) and place them inside `site/plugins/meta-tags`.
12+
Download and copy this repository to `site/plugins/meta-tags`.
13+
14+
### Git submodule
15+
```
16+
git submodule add https://github.com/pedroborges/kirby-meta-tags.git site/plugins/meta-tags
17+
```
18+
19+
### Composer
20+
```
21+
composer require pedroborges/kirby-meta-tags
22+
```
23+
24+
> For Kirby 2, you can download [v1.1.1](https://github.com/pedroborges/kirby-meta-tags/archive/v1.1.1.zip) and copy the files to `site/plugins/meta-tags`.
1325
1426
## Basic Usage
1527
After installing the Meta Tags plugin, you need to add one line to the `head` element on your template, or `header.php` snippet:
@@ -40,7 +52,7 @@ The plugin ships with some default meta tags enabled for your convenience:
4052
```php
4153
return [
4254
// other options...
43-
'pedroborges.metatags.default' => function ($page, $site) {
55+
'pedroborges.meta-tags.default' => function ($page, $site) {
4456
return [
4557
'title' => $site->title(),
4658
'meta' => [
@@ -62,15 +74,15 @@ return [
6274
]
6375
```
6476

65-
**The `pedroborges.metatags.default` option is applied to all pages on your Kirby site.** Of course you can change the defaults. In order to do that, just copy this example to your `site/config/config.php` file and tweak it to fit your website needs.
77+
**The `pedroborges.meta-tags.default` option is applied to all pages on your Kirby site.** Of course you can change the defaults. In order to do that, just copy this example to your `site/config/config.php` file and tweak it to fit your website needs.
6678

6779
### Templates
6880
Following the flexible spirit of Kirby, you also have the option to add template specific meta tags:
6981

7082
```php
7183
return [
7284
// other options...
73-
'pedroborges.metatags.templates' => function ($page, $site) {
85+
'pedroborges.meta-tags.templates' => function ($page, $site) {
7486
return [
7587
'song' => [
7688
'og' => [
@@ -96,13 +108,13 @@ For more information on all the `meta`, `link`, Open Graph and Twitter Card tags
96108
- [Twitter Cards](https://dev.twitter.com/cards/overview)
97109

98110
## Options
99-
Both the `pedroborges.metatags.default` and `pedroborges.metatags.templates` accept similar values:
111+
Both the `pedroborges.meta-tags.default` and `pedroborges.meta-tags.templates` accept similar values:
100112

101-
### `pedroborges.metatags.default`
113+
### `pedroborges.meta-tags.default`
102114
It accepts an array containing any or all of the following keys: `title`, `meta`, `link`, `og`, and `twitter`. With the exception of `title`, all other groups must return an array of key-value pairs. Check out the [tag groups](#tag-groups) section to learn which value types are accepted by each key.
103115

104116
```php
105-
'pedroborges.metatags.default' => function ($page, $site) {
117+
'pedroborges.meta-tags.default' => function ($page, $site) {
106118
return [
107119
'title' => 'Site Name',
108120
'meta' => [ /* meta tags */ ],
@@ -114,11 +126,11 @@ It accepts an array containing any or all of the following keys: `title`, `meta`
114126
}
115127
```
116128

117-
### `pedroborges.metatags.templates`
129+
### `pedroborges.meta-tags.templates`
118130
This option allows you to define a template specific set of meta tags. It must return an array where each key corresponds to the template name you are targeting.
119131

120132
```php
121-
'pedroborges.metatags.default' => function ($page, $site) {
133+
'pedroborges.meta-tags.default' => function ($page, $site) {
122134
return [
123135
'article' => [ /* tags groups */ ],
124136
'about' => [ /* tags groups */ ],
@@ -127,7 +139,7 @@ This option allows you to define a template specific set of meta tags. It must r
127139
}
128140
```
129141

130-
When a key matches the current page template name, it is merged and overrides any repeating properties defined on the `pedroborges.metatags.default` option so you don't have to repeat yourself.
142+
When a key matches the current page template name, it is merged and overrides any repeating properties defined on the `pedroborges.meta-tags.default` option so you don't have to repeat yourself.
131143

132144
## Tag Groups
133145
These groups accept string, closure, or array as their values. Being so flexible, the sky is the limit to what you can do with Meta Tags!
@@ -232,7 +244,7 @@ Where you can define [Open Graph](http://ogp.me) `<meta>` elements.
232244
Of course you can use Open Graph [structured objects](http://ogp.me/#structured). Let's see a blog post example:
233245

234246
```php
235-
'pedroborges.metatags.templates' => function ($page, $site) {
247+
'pedroborges.meta-tags.templates' => function ($page, $site) {
236248
return [
237249
'article' => [ // template name
238250
'og' => [ // tags group name
@@ -368,6 +380,6 @@ Use this tag group to add [JSON Linked Data](https://json-ld.org) schemas to you
368380
All notable changes to this project will be documented at: <https://github.com/pedroborges/kirby-meta-tags/blob/master/changelog.md>
369381

370382
## License
371-
Meta Tags plugin is open-sourced software licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
383+
The Meta Tags plugin is open-sourced software licensed under the [MIT license](http://www.opensource.org/licenses/mit-license.php).
372384

373-
Copyright © 2018 Pedro Borges <[email protected]>
385+
Copyright © 2019 Pedro Borges <[email protected]>

src/MetaTags.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ class MetaTags
2020

2121
public function __construct(Page $page)
2222
{
23-
$this->indentation = option('pedroborges.metatags.indentation', null);
24-
$this->order = option('pedroborges.metatags.order', null);
23+
$this->indentation = option('pedroborges.meta-tags.indentation', null);
24+
$this->order = option('pedroborges.meta-tags.order', null);
2525
$this->tags = new Tags($this->indentation, $this->order);
2626

27-
$templates = option('pedroborges.metatags.templates', []);
28-
$default = option('pedroborges.metatags.default', [
27+
$templates = option('pedroborges.meta-tags.templates', []);
28+
$default = option('pedroborges.meta-tags.default', [
2929
'title' => $page->isHomePage() ? site()->title() : $page->title(),
3030
'meta' => [
3131
'description' => site()->description()
@@ -46,11 +46,11 @@ public function __construct(Page $page)
4646
$templates = is_callable($templates) ? $templates($page, site()) : $templates;
4747

4848
if (! is_array($this->data)) {
49-
throw new Exception('Option "pedroborges.metatags.default" must return an array');
49+
throw new Exception('Option "pedroborges.meta-tags.default" must return an array');
5050
}
5151

5252
if (! is_array($templates)) {
53-
throw new Exception('Option "pedroborges.metatags.templates" must return an array');
53+
throw new Exception('Option "pedroborges.meta-tags.templates" must return an array');
5454
}
5555

5656
if (isset($templates[$page->template()->name()])) {

0 commit comments

Comments
 (0)