From 6283dd44861e4d432a0339de2aeadb1cb8619694 Mon Sep 17 00:00:00 2001 From: Bauke Date: Sun, 7 Jul 2019 13:51:40 +0200 Subject: [PATCH] fix: make feeds contain the 5 most recent posts --- gulpfile.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 612c69f..2be56bb 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -404,6 +404,8 @@ function createFeeds() { } }); const posts = fs.readdirSync(path.join(paths.out, 'posts')); + // Remove the template, that doesn't need to be included + posts.splice(posts.indexOf('template.html'), 1); // Sort the posts descending year and month posts.sort((a, b) => { const yearA = Number(a.replace(/\D/g, '')); @@ -416,12 +418,8 @@ function createFeeds() { return yearB - yearA; }); - for (const post of posts) { - // Skip the template, that doesn't need to be included - if (post.includes('template')) { - continue; - } - + for (let i = 0; i < 5; i++) { + const post = posts[i]; const html = fs.readFileSync(path.join(paths.out, 'posts', post), 'UTF8'); const $ = cheerio.load(html); const title = $('#wrapper>h1').text();