Skip to content

Commit 00c2373

Browse files
committed
Added ability to access sitemap URL without the .xml extension. (needs Grav 1.1.6+)
1 parent fb035dd commit 00c2373

File tree

4 files changed

+17
-2
lines changed

4 files changed

+17
-2
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# v1.7.0
2+
## xx/xx/2016
3+
4+
1. [](#new)
5+
* Use new Grav feature to force output to be XML even when not passed `.xml` in URL
6+
17
# v1.6.2
28
## 07/14/2016
39

blueprints.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ keywords: sitemap, plugin, xml, map, index
1111
bugs: https://github.com/getgrav/grav-plugin-sitemap/issues
1212
license: MIT
1313

14+
dependencies:
15+
- { name: grav, version: '>=1.1.6' }
16+
1417
form:
1518
validation: strict
1619
fields:

pages/sitemap.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
---
2+
template_format: xml
3+
---

sitemap.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
namespace Grav\Plugin;
33

44
use Grav\Common\Data;
5+
use Grav\Common\Page\Page;
56
use Grav\Common\Plugin;
67
use Grav\Common\Uri;
78
use Grav\Common\Page\Pages;
@@ -89,9 +90,11 @@ public function onPagesInitialized()
8990
public function onPageInitialized()
9091
{
9192
// set a dummy page
92-
$home = $this->grav['page']->find('/');
93+
$page = new Page;
94+
$page->init(new \SplFileInfo(__DIR__ . '/pages/sitemap.md'));
95+
9396
unset($this->grav['page']);
94-
$this->grav['page'] = $home;
97+
$this->grav['page'] = $page;
9598
}
9699

97100
/**

0 commit comments

Comments
 (0)