Skip to content

Commit

Permalink
Display tags under posts
Browse files Browse the repository at this point in the history
  • Loading branch information
pdelfan committed Oct 29, 2024
1 parent c8ac74e commit 56f8b94
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/components/contentDisplay/feedPost/FeedPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ export default function FeedPost(props: Props) {
<PostEmbed content={post.post.embed} depth={0} />
)}
</>
)}
)}
<div className="mt-2">
<PostActions post={post.post} />
</div>
Expand Down
21 changes: 21 additions & 0 deletions src/components/dataDisplay/postTag/PostTag.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import Link from "next/link";

interface Props {
tag: string;
}

export default function PostTag(props: Props) {
const { tag } = props;

const encodedTag = encodeURIComponent(tag);

return (
<Link
href={`/dashboard/search?query=%23${encodedTag}`}
className="bg-skin-tertiary px-3 py-1.5 rounded-lg text-sm text-skin-secondary font-medium hover:text-skin-base break-all"
onClick={(e) => e.stopPropagation()}
>
#{tag}
</Link>
);
}
9 changes: 9 additions & 0 deletions src/components/dataDisplay/postText/postText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import Link from "next/link";
import { Fragment } from "react";
import * as Tooltip from "@radix-ui/react-tooltip";
import { BiLinkExternal } from "react-icons/bi";
import PostTag from "../postTag/PostTag";

interface Props {
record: PostView["record"];
Expand All @@ -18,6 +19,7 @@ export default function PostText(props: Props) {
const { record, truncate, mode = "feed" } = props;
const text = AppBskyFeedPost.isRecord(record) && record.text;
const facet = AppBskyFeedPost.isRecord(record) && record.facets;
const tags = AppBskyFeedPost.isRecord(record) && record.tags;

const richText = new RichTextHelper({
text: text.toString(),
Expand Down Expand Up @@ -119,6 +121,13 @@ export default function PostText(props: Props) {
{content.map((segment, i) => (
<Fragment key={`${i}+${text}`}>{segment.component}</Fragment>
))}
{tags && (
<div className="flex flex-wrap gap-2 mt-3">
{tags.map((t, i) => (
<PostTag key={i} tag={t} />
))}
</div>
)}
</div>
);
}
2 changes: 1 addition & 1 deletion src/components/inputs/editor/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export default function Editor(props: Props) {
languages: languages.map((lang) => lang.code),
images,
label,
threadGate,
threadGate,
});

if (!editor) return null;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/hooks/bsky/feed/usePublishPost.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ export default function usePublishPost(props: Props) {
langs: lang,
labels: selfLabels,
reply: reply,
embed: embed,
embed: embed,
});

// add threadGate
Expand Down

0 comments on commit 56f8b94

Please sign in to comment.