From fa4875d78dd9bfe72c9f12b58c8c9f71694fdb5d Mon Sep 17 00:00:00 2001 From: barisusakli Date: Wed, 7 Oct 2015 17:36:27 -0400 Subject: [PATCH] category teaser --- src/controllers/categories.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/controllers/categories.js b/src/controllers/categories.js index b72921c5c8..59068434ad 100644 --- a/src/controllers/categories.js +++ b/src/controllers/categories.js @@ -65,6 +65,15 @@ categoriesController.list = function(req, res, next) { return next(err); } + data.categories.forEach(function(category) { + if (category && Array.isArray(category.posts) && category.posts.length) { + category.teaser = { + url: nconf.get('relative_path') + '/topic/' + category.posts[0].topic.slug + '/' + category.posts[0].index, + timestampISO: category.posts[0].relativeTime + }; + } + }); + data.title = '[[pages:categories]]'; if (req.path.startsWith('/api/categories') || req.path.startsWith('/categories')) { data.breadcrumbs = helpers.buildBreadcrumbs([{text: data.title}]);