Articles rendering system

This commit is contained in:
Clément GOUIN
2019-06-20 13:49:44 +02:00
parent 69d05e3900
commit b7a2fd0740
7 changed files with 131 additions and 12 deletions
+4 -4
View File
@@ -76,7 +76,7 @@ module.exports = (config) => {
.filter((matches) => matches && matches.length > 1);
if (paths.length === 0)
cb(null, []);
const list = [];
const articles = {};
let remaining = 0;
paths.forEach((matches) => {
const article = {
@@ -94,11 +94,11 @@ 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);
list.push(article);
article.url = path.join(article.path, article.escapedTitle)+'/';
articles[article.path]=article;
remaining--;
if (remaining === 0)
cb(null, list);
cb(null, articles);
});
});