0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

Wired url for search results

refs https://github.com/TryGhost/Team/issues/1665

- wires url for authors, posts and tags to allow redirect on click
This commit is contained in:
Rishabh 2022-07-06 12:40:28 +02:00
parent 09ba52039c
commit 55757f3bd1

View file

@ -165,11 +165,19 @@ function ClearButton() {
); );
} }
function TagListItem({title}) { function TagListItem({tag}) {
const {name, url} = tag;
return ( return (
<div className='flex items-center py-3 -mx-7 px-7 hover:bg-gray-100 cursor-pointer'> <div
className='flex items-center py-3 -mx-7 px-7 hover:bg-gray-100 cursor-pointer'
onClick={() => {
if (url) {
window.location.href = url;
}
}}
>
<p className='mr-2 text-sm font-bold text-neutral-400'>#</p> <p className='mr-2 text-sm font-bold text-neutral-400'>#</p>
<h2 className='text-[1.65rem] font-medium leading-tight text-neutral-900'>{title}</h2> <h2 className='text-[1.65rem] font-medium leading-tight text-neutral-900'>{name}</h2>
</div> </div>
); );
} }
@ -183,7 +191,7 @@ function TagResults({tags}) {
return ( return (
<TagListItem <TagListItem
key={d.name} key={d.name}
title={d.name} tag={d}
/> />
); );
}); });
@ -195,12 +203,12 @@ function TagResults({tags}) {
); );
} }
function PostListItem({title, excerpt, slug}) { function PostListItem({post}) {
const {siteUrl} = useContext(AppContext); const {title, excerpt, url} = post;
return ( return (
<div className='py-3 -mx-7 px-7 hover:bg-neutral-100 cursor-pointer' onClick={() => { <div className='py-3 -mx-7 px-7 hover:bg-neutral-100 cursor-pointer' onClick={() => {
if (slug) { if (url) {
window.location.href = `${siteUrl}${slug}`; window.location.href = url;
} }
}}> }}>
<h2 className='text-[1.65rem] font-medium leading-tight text-neutral-900'>{title}</h2> <h2 className='text-[1.65rem] font-medium leading-tight text-neutral-900'>{title}</h2>
@ -218,9 +226,7 @@ function PostResults({posts}) {
return ( return (
<PostListItem <PostListItem
key={d.title} key={d.title}
title={d.title} post={d}
excerpt={d.excerpt}
slug={d.slug}
/> />
); );
}); });
@ -232,9 +238,17 @@ function PostResults({posts}) {
); );
} }
function AuthorListItem({name, avatar}) { function AuthorListItem({author}) {
const {name, avatar, url} = author;
return ( return (
<div className='py-3 -mx-7 px-7 hover:bg-neutral-100 cursor-pointer flex items-center'> <div
className='py-3 -mx-7 px-7 hover:bg-neutral-100 cursor-pointer flex items-center'
onClick={() => {
if (url) {
window.location.href = url;
}
}}
>
<AuthorAvatar name={name} avatar={avatar} /> <AuthorAvatar name={name} avatar={avatar} />
<h2 className='text-[1.65rem] font-medium leading-tight text-neutral-900'>{name}</h2> <h2 className='text-[1.65rem] font-medium leading-tight text-neutral-900'>{name}</h2>
</div> </div>
@ -262,8 +276,7 @@ function AuthorResults({authors}) {
return ( return (
<AuthorListItem <AuthorListItem
key={d.name} key={d.name}
name={d.name} author={d}
avatar={d.avatar}
/> />
); );
}); });