diff --git a/admin/templates/comments.html.twig b/admin/templates/comments.html.twig
index f5fcc04..6fea510 100644
--- a/admin/templates/comments.html.twig
+++ b/admin/templates/comments.html.twig
@@ -105,32 +105,28 @@
Showing {{grav.twig.comments.totalRetrieved}} comments of {{grav.twig.comments.totalAvailable}}
- Recently commented pages
+ {% if grav.twig.pages %}
+ Recently commented pages
-
-
-
-
- Page |
-
-
-
- {% for page in grav.twig.pages %}
-
- {{page.title}} |
-
-
+
+
+
+
+ Page |
+
+
- {% endfor %}
-
-
-
- {% if grav.twig.comments.totalRetrieved < grav.twig.comments.totalAvailable %}
-
- {% endif %}
-
+ {% for page in grav.twig.pages %}
+
+ {{page.title}} |
+
+
+
+ {% endfor %}
+
+
+
+ {% endif %}
{% endblock %}
diff --git a/comments.php b/comments.php
index 2e64f53..80d32b2 100644
--- a/comments.php
+++ b/comments.php
@@ -129,6 +129,7 @@ class CommentsPlugin extends Plugin
}
$this->grav['twig']->comments = $comments;
+ $this->grav['twig']->pages = $this->fetchPages();
}
}
@@ -295,6 +296,27 @@ class CommentsPlugin extends Plugin
return $this->getDataFromFilename($filename)['comments'];
}
+ /**
+ * Return the latest commented pages
+ */
+ private function fetchPages() {
+ $files = [];
+ $files = $this->getFilesOrderedByModifiedDate();
+
+ $pages = [];
+
+ foreach($files as $file) {
+ $pages[] = [
+ 'title' => $file->data['title'],
+ 'commentsCount' => count($file->data['comments']),
+ 'lastCommentDate' => gmdate('D, d M Y H:i:s', $file->modifiedDate)
+ ];
+ }
+
+ return $pages;
+ }
+
+
/**
* Given a data file route, return the YAML content already parsed
*/