Skip to content

Commit

Permalink
#1
Browse files Browse the repository at this point in the history
Signed-off-by: Bruno Meilick <b@bnomei.com>
  • Loading branch information
bnomei committed Jan 8, 2019
1 parent 484c0dc commit a86f4aa
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 4 deletions.
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ The plugin generates automatic defaults for the starterkit. You do not have to e
```php
<?php
return [
'bnomei.robots-txt.content' => null,
'bnomei.robots-txt.sitemap' => null,
'bnomei.robots-txt.groups' => [
'bnomei.robots-txt.content' => null, // string or callback
'bnomei.robots-txt.sitemap' => null, // string or callback
'bnomei.robots-txt.groups' => [ // array or callback
'*' => [ // user-agent
'disallow' => [
'/kirby',
Expand All @@ -46,6 +46,16 @@ allow: /media',
];
```

**using a callback**
```php
<?php
return [
'bnomei.robots-txt.content' => function() {
return site()->myRobotsTxtContentField()->value();
},
];
```

**sitemap and multiple user-agents**
```php
<?php
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "bnomei/kirby3-robots-txt",
"type": "plugin",
"description": "Manage the robots.txt from the Kirby config file",
"version": "1.0.2",
"version": "1.0.3",
"license": "MIT",
"authors": [
{
Expand Down Expand Up @@ -43,6 +43,7 @@
},
"scripts": {
"zip": [
"touch kirby3-robots-txt.zip",
"rm kirby3-robots-txt.zip",
"composer install --no-dev",
"composer remove getkirby/cms",
Expand Down
9 changes: 9 additions & 0 deletions config.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,23 @@
'action' => function () {
$txt = [];
if ($str = option('bnomei.robots-txt.content')) {
if(is_callable($str)) {
$str = $str();
}
$txt[] = $str;
}

if ($sitemap = option('bnomei.robots-txt.sitemap')) {
if(is_callable($sitemap)) {
$sitemap = $sitemap();
}
$txt[] = 'sitemap: ' . url($sitemap);
}

if ($groups = option('bnomei.robots-txt.groups')) {
if(is_callable($groups)) {
$groups = $groups();
}
if (is_array($groups)) {
foreach ($groups as $useragent => $group) {
$txt[] = 'user-agent: ' . $useragent;
Expand Down

0 comments on commit a86f4aa

Please sign in to comment.