From 46db92b9481d6d15f5c749170ec5559558f6bffb Mon Sep 17 00:00:00 2001 From: Cory Dransfeldt Date: Wed, 6 Sep 2023 12:57:53 -0700 Subject: [PATCH] chore: fuzzy search for date key instead of control flow --- config/filters.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/config/filters.js b/config/filters.js index 52465553..3961a930 100644 --- a/config/filters.js +++ b/config/filters.js @@ -25,18 +25,14 @@ module.exports = { }, normalizeEntries: (entries) => { return entries.map((entry) => { + const dateKey = Object.keys(entry).find((key) => key.includes('date')) + const date = entry[dateKey] let excerpt = '' - let date = '' // set the entry excerpt if (entry.data?.post_excerpt) excerpt = entry.data.post_excerpt if (entry.description) excerpt = entry.description - // set the entry date - if (entry.date) date = entry.date - if (entry.dateAdded) date = entry.dateAdded - if (entry.date_published) date = entry.date_published - // if there's a valid entry return a normalized object if (entry) { return {