From f6bad18440010466331f401e5ba2c7ec52aa5c2c Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Sun, 4 Sep 2022 16:31:31 +0100 Subject: [PATCH] bloggers: deduplicate by author name. If you have multiple feeds referenced in feeds.json, it is undefined which one it will pick. --- src/bloggers.11tydata.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/bloggers.11tydata.js b/src/bloggers.11tydata.js index 3fcdaa4..cb7f90b 100644 --- a/src/bloggers.11tydata.js +++ b/src/bloggers.11tydata.js @@ -7,7 +7,11 @@ const shuffle = require("./lib/shuffle.js"); const fetch_github_user_info = require("./lib/fetch_github_user_info.js"); module.exports = async function() { - const feeds_data = JSON.parse(await fs.promises.readFile(path.resolve(__dirname, "../feeds.json"), "utf-8")); + const author_names = new Set(); + + const feeds_data = JSON.parse(await fs.promises.readFile(path.resolve(__dirname, "../feeds.json"), "utf-8")) + .filter(feed_item => !author_names.has(feed_item.author_name) && author_names.add(feed_item.author_name)); + await Promise.all(feeds_data.map(fetch_github_user_info)); shuffle(feeds_data); // Don't give any 1 person the advantage