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
This commit is contained in:
Rishabh 2022-07-08 11:32:50 +02:00
parent 64bb0b3c50
commit eb59bea5c7

View File

@ -148,8 +148,8 @@ function SearchClearIcon() {
}
function Loading() {
const {indexComplete} = useContext(AppContext);
if (!indexComplete) {
const {indexComplete, searchValue} = useContext(AppContext);
if (!indexComplete && searchValue) {
return (
<CircleAnimated className='shrink-0' />
);
@ -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) {