Skip to content

Commit

Permalink
Merge branch 'release/2.0.0'
Browse files Browse the repository at this point in the history
  • Loading branch information
rhukster committed Jul 1, 2020
2 parents 63e68b0 + cb846c9 commit c2ac914
Show file tree
Hide file tree
Showing 18 changed files with 833 additions and 39 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# v2.0.0
## 07/01/2020

1. [](#new)
* Added a new `Ignore External URLs` option that defaults to `true`
* Added a new `Ignore Protected Pages` option that defaults to `true` [#62](https://github.com/getgrav/grav-plugin-sitemap/issues/62)
* Added a new `onSitemapProcessed()` event to allow for dynamic manipulation of the sitemap
1. [](#improved)
* Improved `SitemapEntry` to allow setting via constructor
* Added `changefreq` and `priority` to manually and dynamically added entries
* Use composer for autoloading
1. [](#bugfix)
* Force a fallback to `en` to ensure you can't get `null/false` language [#74](https://github.com/getgrav/grav-plugin-sitemap/issues/74)

# v1.9.5
## 04/27/2020

Expand Down
40 changes: 37 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,25 @@ The `sitemap` plugin works out of the box. You can just go directly to `http://y

```
enabled: true
changefreq: daily
priority: !!float 1
route: '/sitemap'
ignore_external: true
ignores:
- /blog/blog-post-to-ignore
- /ignore-this-route
- /ignore-children-of-this-route/.*
additions:
-
location: /something-special
lastmod: '2020-04-16'
changefreq: hourly
priority: 0.3
-
location: /something-else
lastmod: '2020-04-17'
changefreq: weekly
priority: 0.2
```

You can ignore your own pages by providing a list of routes to ignore. You can also use a page's Frontmatter to signal that the sitemap should ignore it:
Expand All @@ -61,6 +75,26 @@ You can manually add URLs to the sitemap using the Admin settings, or by adding
```
additions:
-
location: /not-a-grav-url
lastmod: '2017-04-06'
```
location: /something-special
lastmod: '2020-04-16'
changefreq: hourly
priority: 0.3
```

## Dynamically adding pages to the sitemap

If you have some dynamic content being added to your site via another plugin, or perhaps a 3rd party API, you can now add them dynamically to the sitemap with a simple event:

Make sure you are subscribed to the `` event then add simply add your entry to the sitemap like this:

```php
public function onSitemapProcessed(\RocketTheme\Toolbox\Event\Event $e)
{
$sitemap = $e['sitemap'];
$location = \Grav\Common\Utils::url('/foo-location', true);
$sitemap['/foo'] = new \Grav\Plugin\Sitemap\SitemapEntry($location, '2020-07-02', 'weekly', '2.0');
$e['sitemap'] = $sitemap;
}
```

The use `Utils::url()` method allow us to easily create the correct full URL by passing it a route plus the optional `true` parameter.
98 changes: 76 additions & 22 deletions blueprints.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: Sitemap
version: 2.0.0
description: "Provide automatically generated **XML sitemaps** with this very useful, but simple to configure, Grav plugin."
slug: sitemap
type: plugin
version: 1.9.5
description: "Provide automatically generated **XML sitemaps** with this very useful, but simple to configure, Grav plugin."
icon: map-marker
author:
name: Team Grav
Expand All @@ -14,7 +14,7 @@ bugs: https://github.com/getgrav/grav-plugin-sitemap/issues
license: MIT

dependencies:
- { name: grav, version: '>=1.1.6' }
- { name: grav, version: '>=1.6.0' }

form:
validation: strict
Expand All @@ -29,7 +29,6 @@ form:
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool

changefreq:
type: select
label: PLUGIN_SITEMAP.CHANGEFREQ
Expand Down Expand Up @@ -68,26 +67,81 @@ form:
label: PLUGIN_SITEMAP.ROUTE
placeholder: /sitemap
validate:
pattern: "/([a-z\-_]+/?)+"
pattern: "/([a-z-_]+/?)+"

ignore_external:
type: toggle
label: PLUGIN_SITEMAP.IGNORE_EXTERNAL
help: PLUGIN_SITEMAP.IGNORE_EXTERNAL_HELP
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool

ignore_protected:
type: toggle
label: PLUGIN_SITEMAP.IGNORE_PROTECTED
help: PLUGIN_SITEMAP.IGNORE_PROTECTED_HELP
highlight: 1
default: 1
options:
1: PLUGIN_ADMIN.ENABLED
0: PLUGIN_ADMIN.DISABLED
validate:
type: bool

ignores:
type: array
label: PLUGIN_SITEMAP.IGNORES
help: PLUGIN_SITEMAP.IGNORES_HELP
value_only: true
placeholder_value: /ignore-this-route
type: array
label: PLUGIN_SITEMAP.IGNORES
help: PLUGIN_SITEMAP.IGNORES_HELP
value_only: true
placeholder_value: '/ignore-this-route'

additions:
type: list
label: PLUGIN_SITEMAP.ADDITIONS
help: PLUGIN_SITEMAP.ADDITIONS_HELP
type: list
label: PLUGIN_SITEMAP.ADDITIONS
help: PLUGIN_SITEMAP.ADDITIONS_HELP

fields:
.location:
type: text
label: PLUGIN_SITEMAP.LOCATION
placeholder: "/not-a-grav-url"
.lastmod:
type: text
label: PLUGIN_SITEMAP.LASTMOD
placeholder: "2017-04-06"
fields:
.location:
type: text
label: PLUGIN_SITEMAP.LOCATION
placeholder: "/not-a-grav-url"
.lastmod:
type: text
label: PLUGIN_SITEMAP.LASTMOD
placeholder: "2017-04-06"
.changefreq:
type: select
label: PLUGIN_SITEMAP.CHANGEFREQ
default: ''
options:
'': PLUGIN_SITEMAP.CHANGEFREQ_DEFAULT
always: PLUGIN_SITEMAP.CHANGEFREQ_ALWAYS
hourly: PLUGIN_SITEMAP.CHANGEFREQ_HOURLY
daily: PLUGIN_SITEMAP.CHANGEFREQ_DAILY
weekly: PLUGIN_SITEMAP.CHANGEFREQ_WEEKLY
monthly: PLUGIN_SITEMAP.CHANGEFREQ_MONTHLY
yearly: PLUGIN_SITEMAP.CHANGEFREQ_YEARLY
never: PLUGIN_SITEMAP.CHANGEFREQ_NEVER
.priority:
type: select
label: PLUGIN_SITEMAP.PRIORITY
default: ''
options:
'': PLUGIN_SITEMAP.PRIORITY_USE_GLOBAL
'0.1': 0.1
'0.2': 0.2
'0.3': 0.3
'0.4': 0.4
'0.5': 0.5
'0.6': 0.6
'0.7': 0.7
'0.8': 0.8
'0.9': 0.9
'1.0': 1.0
validate:
type: float
20 changes: 19 additions & 1 deletion classes/sitemapentry.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
namespace Grav\Plugin;
namespace Grav\Plugin\Sitemap;

class SitemapEntry
{
Expand All @@ -8,4 +8,22 @@ class SitemapEntry
public $changefreq;
public $priority;
public $image;

/**
* SitemapEntry constructor.
*
* @param null $location
* @param null $lastmod
* @param null $changefreq
* @param null $priority
* @param null $image
*/
public function __construct($location = null, $lastmod = null, $changefreq = null, $priority = null, $image = null)
{
$this->location = $location;
$this->lastmod = $lastmod;
$this->changefreq = $changefreq;
$this->priority = $priority;
$this->image = $image;
}
}
30 changes: 30 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "trilbymedia/sitemap",
"type": "grav-sitemap",
"description": "Provide automatically generated **XML sitemaps** with this very useful, but simple to configure, Grav plugin.",
"keywords": ["plugin"],
"homepage": "https://github.com/getgrav/grav-plugin-sitemap",
"license": "MIT",
"authors": [
{
"name": "Team Grav",
"email": "[email protected]",
"homepage": "http://getgrav.org",
"role": "Developer"
}
],
"require": {
"php": ">=7.1.3"
},
"autoload": {
"psr-4": {
"Grav\\Plugin\\Sitemap\\": "classes/"
},
"classmap": ["sitemap.php"]
},
"config": {
"platform": {
"php": "7.1.3"
}
}
}
23 changes: 23 additions & 0 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion languages.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,10 @@ en:
ADDITIONS_HELP: 'Add external URLs to the sitemap'
LOCATION: 'The URL location'
LASTMOD: 'Last modification e.g. 2017-04-06'

IGNORE_EXTERNAL: 'Ignore External URLs'
IGNORE_EXTERNAL_HELP: 'By default Sitemap hides pages that have an `external` URL'
IGNORE_PROTECTED: 'Ignore Protected Pages'
IGNORE_PROTECTED_HELP: 'Ignore pages that custom "access" set to protect them via a login'
ru:
PLUGIN_SITEMAP:
SITEMAP: 'Карта сайта'
Expand Down
Loading

0 comments on commit c2ac914

Please sign in to comment.