-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
executable file
·77 lines (72 loc) · 2.62 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
use Kirby\Exception\InvalidArgumentException;
use Kirby\Toolkit\Str;
use Kirby\Toolkit\Query;
use Kirby\Cms\Section;
Kirby::plugin('reh/seo-preview-section', [
'sections' => [
'seopreview' => [
'props' => [
'headline' => function( string $headline = 'SEO preview' ) {
return $headline;
},
'titleField' => function( string $query = 'metatitle' ) {
return $query;
},
'defaultTitle' => function( string $query = 'page.title' ) {
return $query;
},
'separator' => function( string $separator = ' ' ) {
return $separator;
},
'baseTitle' => function( string $query = 'site.title' ) {
return $query;
},
'descriptionField' => function( string $query = 'metadescription' ) {
return $query;
},
'defaultDescription' => function( string $query = 'page.text' ) {
return $query;
},
],
'computed' => [
'url' => function() {
return $this->model()->url();
},
'siteTitle' => function() {
return site()->title()->value();
},
'pageTitle' => function() {
return $this->model()->title()->value();
},
'isSite' => function() {
if($this->model() == site()) {
return true;
} else {
return false;
}
},
'seoDefaultTitle' => function() {
return strip_tags($this->query($this->defaultTitle));
},
'seoBaseTitle' => function() {
return $this->query($this->baseTitle)->value();
},
'seoDefaultDescription' => function() {
return strip_tags( preg_replace("/<br>/", " ", $this->query($this->defaultDescription)) );
},
],
'methods' => [
'query' => function($q) {
$qery = new Query($q, [
'site' => site(),
'page' => $this->model(),
'pages' => site()->pages()
]);
$result = $qery->result();
return $result;
}
]
]
]
]);