Skip to content

Commit

Permalink
Added ability to access sitemap URL without the .xml extension. (ne…
Browse files Browse the repository at this point in the history
…eds Grav 1.1.6+)
  • Loading branch information
rhukster committed Sep 30, 2016
1 parent fb035dd commit 00c2373
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
# v1.7.0
## xx/xx/2016

1. [](#new)
* Use new Grav feature to force output to be XML even when not passed `.xml` in URL

# v1.6.2
## 07/14/2016

Expand Down
3 changes: 3 additions & 0 deletions blueprints.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ keywords: sitemap, plugin, xml, map, index
bugs: https://github.com/getgrav/grav-plugin-sitemap/issues
license: MIT

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

form:
validation: strict
fields:
Expand Down
3 changes: 3 additions & 0 deletions pages/sitemap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
template_format: xml
---
7 changes: 5 additions & 2 deletions sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
namespace Grav\Plugin;

use Grav\Common\Data;
use Grav\Common\Page\Page;
use Grav\Common\Plugin;
use Grav\Common\Uri;
use Grav\Common\Page\Pages;
Expand Down Expand Up @@ -89,9 +90,11 @@ public function onPagesInitialized()
public function onPageInitialized()
{
// set a dummy page
$home = $this->grav['page']->find('/');
$page = new Page;
$page->init(new \SplFileInfo(__DIR__ . '/pages/sitemap.md'));

unset($this->grav['page']);
$this->grav['page'] = $home;
$this->grav['page'] = $page;
}

/**
Expand Down

0 comments on commit 00c2373

Please sign in to comment.