From eb59bea5c756b383c55f98e1de19e7841b80db5c Mon Sep 17 00:00:00 2001 From: Rishabh Date: Fri, 8 Jul 2022 11:32:50 +0200 Subject: [PATCH] Removed author and tag sections with invalid urls refs https://github.com/TryGhost/Team/issues/1665 - if taxonomy is disabled, author and tag urls are 404s. - removes author/tag section if 404 --- ghost/sodo-search/src/components/PopupModal.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/ghost/sodo-search/src/components/PopupModal.js b/ghost/sodo-search/src/components/PopupModal.js index 89cb4c9265..2a45600c48 100644 --- a/ghost/sodo-search/src/components/PopupModal.js +++ b/ghost/sodo-search/src/components/PopupModal.js @@ -148,8 +148,8 @@ function SearchClearIcon() { } function Loading() { - const {indexComplete} = useContext(AppContext); - if (!indexComplete) { + const {indexComplete, searchValue} = useContext(AppContext); + if (!indexComplete && searchValue) { return ( ); @@ -448,6 +448,16 @@ function SearchResultBox() { filteredTags = searchResults?.tags || []; } + filteredAuthors = filteredAuthors.filter((author) => { + const invalidUrlRegex = /\/404\/$/; + return !(author?.url && invalidUrlRegex.test(author?.url)); + }); + + filteredTags = filteredTags.filter((tag) => { + const invalidUrlRegex = /\/404\/$/; + return !(tag?.url && invalidUrlRegex.test(tag?.url)); + }); + const hasResults = filteredPosts?.length || filteredAuthors?.length || filteredTags?.length; if (hasResults) {