From 4d1b7736befa0247ed3b5a83032fea1f515e2579 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Xalambr=C3=AD?= Date: Fri, 29 Dec 2023 18:27:24 -0500 Subject: [PATCH] List searches on home --- app/routes/cms._index/queries.ts | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/routes/cms._index/queries.ts b/app/routes/cms._index/queries.ts index 593ff4a..dcff454 100644 --- a/app/routes/cms._index/queries.ts +++ b/app/routes/cms._index/queries.ts @@ -52,17 +52,23 @@ export async function createQuickLike( export async function queryLastDaySearch(context: AppLoadContext) { let cache = new Cache.KVStore(context.kv.cache, context.waitUntil); - let [articles, tutorials] = await Promise.all([ + let [articles, tutorials, feedArticles, feedTutorials] = await Promise.all([ cache.list("articles:search:"), cache.list("tutorials:search:"), + cache.list("feed:articles:search:"), + cache.list("feed:tutorials:search:"), ]); return { - articles: articles.map((key) => key.replace("articles:search:", "")), - tutorials: tutorials.map((key) => { - key = key.replace("tutorials:search:", ""); - if (!key.startsWith("tech:")) return key; - return key.replace("tech:", ""); - }), + articles: [...articles, ...feedArticles] + .map((key) => key.replace("articles:search:", "").replace("feed:", "")) + .sort((a, b) => a.localeCompare(b)), + tutorials: [...tutorials, ...feedTutorials] + .map((key) => { + key = key.replace("tutorials:search:", "").replace("feed:", ""); + if (!key.startsWith("tech:")) return key; + return key.replace("tech:", ""); + }) + .sort((a, b) => a.localeCompare(b)), }; }