From 9e2818004a70e3d316ae30a0f2b96b5542f38b56 Mon Sep 17 00:00:00 2001 From: Ayo Date: Thu, 15 Jun 2023 08:43:41 +0200 Subject: [PATCH] fix: history heading shows when only index is cached --- src/components/Library.astro | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/components/Library.astro b/src/components/Library.astro index 2144892..930acaa 100644 --- a/src/components/Library.astro +++ b/src/components/Library.astro @@ -28,19 +28,18 @@ const {postDivSelector, skipSave = false} = Astro.props; } } - const cachedRequests = await cache.keys(); - const list = document.querySelector('#post-list'); + const cachedRequests = (await cache.keys()) + .filter(request => { + const urlObj = new URL(request.url); + return urlObj.search !== ''; + }); if(cachedRequests?.length) { + const list = document.querySelector('#post-list'); const heading = document.querySelector('#library span#heading') as HTMLHeadingElement; heading.innerHTML = 'History'; cachedRequests - // temporary delete all cached errors - .filter(request => { - const urlObj = new URL(request.url); - return urlObj.search !== ''; - }) .reverse() .forEach(async (request) => { const {url} = request;