Skip to content

Commit

Permalink
add link embeds to quote posts
Browse files Browse the repository at this point in the history
  • Loading branch information
dickeyy committed Nov 20, 2024
1 parent f87918f commit 0845384
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/components/post/embeds/link-embed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export interface LinkEmbedType {

export default function LinkEmbed({ embed }: { embed: LinkEmbedType }) {
return (
<Link href={embed.uri} target="_blank" rel="noreferrer">
<Link href={embed.uri || "#"} target="_blank" rel="noreferrer">
<Card className="p-0 hover:bg-card/40 transition-all bg-background">
<CardContent className="p-0 bg-transparent">
{embed.thumb && (
Expand Down
5 changes: 5 additions & 0 deletions src/components/post/embeds/quote-post.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import RichTextRenderer from "@/components/rich-text-renderer";
import { genRichText, parseRichText, Segment } from "@/utils/text-processor";
import { useEffect, useState } from "react";
import AuthorInfo from "../author-info";
import LinkEmbed, { LinkEmbedType } from "./link-embed";
import MediaGrid from "./media-grid";
import { EmbedVideo, VideoEmbed } from "./video-embed";

export default function QuotePost({ post }: { post: any }) {
const [textSegments, setTextSegments] = useState<Segment[]>([]);
const [images, setImages] = useState([]);
const [video, setVideo] = useState<EmbedVideo>();
const [link, setLink] = useState<LinkEmbedType>();

useEffect(() => {
async function processText() {
Expand All @@ -26,6 +28,8 @@ export default function QuotePost({ post }: { post: any }) {
setImages(embed.images);
} else if (embed.$type === "app.bsky.embed.video#view") {
setVideo(embed);
} else if (embed.$type === "app.bsky.embed.external#view") {
setLink(embed.external);
}
});
}
Expand Down Expand Up @@ -55,6 +59,7 @@ export default function QuotePost({ post }: { post: any }) {
/>
)}
{video && <VideoEmbed video={video} />}
{link && <LinkEmbed embed={link} />}
</div>
);
}

0 comments on commit 0845384

Please sign in to comment.