smaller trending hashtags listing

This commit is contained in:
Martti Malmi
2023-11-24 17:18:58 +02:00
parent b7545295d4
commit 4813e4e4f1
2 changed files with 20 additions and 5 deletions

View File

@ -5,8 +5,10 @@ import NostrBandApi from "@/External/NostrBand";
import { ErrorOrOffline } from "./ErrorOrOffline";
import { HashTagHeader } from "@/Pages/HashTagsPage";
import { useLocale } from "@/IntlProvider";
import classNames from "classnames";
import {Link} from "react-router-dom";
export default function TrendingHashtags({ title, count = Infinity }: { title?: ReactNode; count?: number }) {
export default function TrendingHashtags({ title, count = Infinity, short }: { title?: ReactNode; count?: number, short?: boolean }) {
const [hashtags, setHashtags] = useState<Array<{ hashtag: string; posts: number }>>();
const [error, setError] = useState<Error>();
const { lang } = useLocale();
@ -31,9 +33,22 @@ export default function TrendingHashtags({ title, count = Infinity }: { title?:
return (
<>
{title}
{hashtags.map(a => (
<HashTagHeader tag={a.hashtag} events={a.posts} className="bb p" />
))}
{hashtags.map(a => {
if (short) {
// return just the hashtag (not HashTagHeader) and post count
return (
<div className="my-1 font-bold" key={a.hashtag}>
<Link to={`/t/${a.hashtag}`} key={a.hashtag}>
#{a.hashtag}
</Link>
</div>
);
} else {
return (
<HashTagHeader tag={a.hashtag} events={a.posts} className={classNames("bb", { p: !short })} />
);
}
})}
</>
);
}