Skip to content

Commit

Permalink
Sitemap 1.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Awilum committed Dec 28, 2018
1 parent 26c95dc commit 6bc176e
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# v1.3.0, 2018-12-28
* Updates for Flextype 0.8.0

# v1.2.0, 2018-12-17
* Updates for Flextype 0.7.4

Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Sitemap Plugin for [Flextype](http://flextype.org/)
![version](https://img.shields.io/badge/version-1.2.0-brightgreen.svg?style=flat-square "Version")
![Flextype](https://img.shields.io/badge/Flextype-0.7.4-green.svg?style=flat-square "Flextype Version")
![version](https://img.shields.io/badge/version-1.3.0-brightgreen.svg?style=flat-square "Version")
![Flextype](https://img.shields.io/badge/Flextype-0.8.0-green.svg?style=flat-square "Flextype Version")
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg?style=flat-square)](https://github.com/flextype-plugins/tiny-url/blob/master/LICENSE.txt)

Sitemap plugin provide automatically generated XML sitemap for Flextype.
Expand Down
10 changes: 5 additions & 5 deletions sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,19 +20,19 @@
//
// Add listner for onCurrentPageAfterProcessed event
//
Event::addListener('onCurrentPageBeforeLoaded', function () {
Event::addListener('onCurrentEntryBeforeLoaded', function () {
if (Http::getUriSegment(0) == 'sitemap.xml') {
Http::setResponseStatus(200);
Http::setRequestHeaders('Content-Type: text/xml; charset=utf-8');

foreach (Content::getPages('', false, 'date') as $page) {
if ($page['slug'] !== '404' && !(isset($page['visibility']) && ($page['visibility'] === 'draft' || $page['visibility'] === 'hidden'))) {
$pages[] = $page;
foreach (Entries::getEntries('', 'date') as $entry) {
if ($entry['slug'] !== '404' && !(isset($entry['visibility']) && ($entry['visibility'] === 'draft' || $entry['visibility'] === 'hidden'))) {
$entries[] = $entry;
}
}

Themes::view('sitemap/views/sitemap')
->assign('pages', $pages)
->assign('entries', $entries)
->display();

Http::requestShutdown();
Expand Down
2 changes: 1 addition & 1 deletion sitemap.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: Sitemap
version: 1.2.0
version: 1.3.0
description: "Provide automatically generated XML sitemap."
author:
name: Sergey Romanenko
Expand Down
8 changes: 4 additions & 4 deletions views/sitemap.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?= '<?xml version="1.0" encoding="UTF-8"?>'."\n"; ?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<?php foreach($pages as $page): ?>
<?php foreach($entries as $entry): ?>
<url>
<loc><?= $page['url'] ?></loc>
<lastmod><?= $page['date'] ?></lastmod>
<changefreq><?= $page['changefreq'] ?? '1.0' ?></changefreq>
<loc><?= $entry['url'] ?></loc>
<lastmod><?= $entry['date'] ?></lastmod>
<changefreq><?= $entry['changefreq'] ?? '1.0' ?></changefreq>
<priority>1.0</priority>
</url>
<?php endforeach ?>
Expand Down

0 comments on commit 6bc176e

Please sign in to comment.