Accounting for indexed posts.
This commit is contained in:
@@ -12,8 +12,8 @@ async function writeToIndex(posts, user) {
|
||||
|
||||
// Individual posts are wrapped in [] to get a YAML array value for each individual item, allowing them to be joined manually with a newline
|
||||
// between each entry to improve human readability of the index while maintaining a valid YAML list
|
||||
const oldEntries = user.indexed.map(entry => yaml.safeDump([entry]));
|
||||
const newEntries = posts.map(post => yaml.safeDump([{
|
||||
const originalEntries = user.indexed.original.map(entry => yaml.safeDump([entry]));
|
||||
const newAndUpdatedEntries = posts.concat(user.indexed.updated).map(post => yaml.safeDump([{
|
||||
id: post.id,
|
||||
subreddit: post.subreddit,
|
||||
permalink: post.permalink,
|
||||
@@ -24,7 +24,7 @@ async function writeToIndex(posts, user) {
|
||||
title: post.title,
|
||||
}]));
|
||||
|
||||
const entries = newEntries.concat(oldEntries).join('\n');
|
||||
const entries = newAndUpdatedEntries.concat(originalEntries).join('\n');
|
||||
|
||||
return fs.writeFile(filename, entries);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user