Bauke/tildes-issue-log
Bauke
/
tildes-issue-log
Archived
1
Fork 0

fix: make feeds contain the 5 most recent posts

This commit is contained in:
Bauke 2019-07-07 13:51:40 +02:00
parent e1ae6da34e
commit 6283dd4486
Signed by: Bauke
GPG Key ID: C1C0F29952BCF558
1 changed files with 4 additions and 6 deletions

View File

@ -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();