fix: make feeds contain the 5 most recent posts
This commit is contained in:
parent
e1ae6da34e
commit
6283dd4486
10
gulpfile.js
10
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();
|
||||
|
|
Reference in New Issue