Article rendering tests

This commit is contained in:
Clément GOUIN
2019-06-20 14:18:49 +02:00
parent b7a2fd0740
commit 3df43b4872
4 changed files with 112 additions and 33 deletions
+3 -3
View File
@@ -75,7 +75,7 @@ module.exports = (config) => {
.map((path) => path.match(/^\/(\d{4})\/(\d{2})\/(\d{2})\/$/))
.filter((matches) => matches && matches.length > 1);
if (paths.length === 0)
cb(null, []);
cb(null, {});
const articles = {};
let remaining = 0;
paths.forEach((matches) => {
@@ -94,8 +94,8 @@ module.exports = (config) => {
article.title = info.title || config['article']['default_title'];
article.thumbnail = info.thumbnail ? path.join(article.path, info.thumbnail) : config['article']['default_thumbnail'];
article.escapedTitle = article.title.toLowerCase().replace(/[^\w]/gm, ' ').trim().replace(/ /gm, '_');
article.url = path.join(article.path, article.escapedTitle)+'/';
articles[article.path]=article;
article.url = '/' + path.join(article.path, article.escapedTitle) + '/';
articles[article.path] = article;
remaining--;
if (remaining === 0)
cb(null, articles);