From 8e9651cec49d08e28baf0dd5ed6f9fae0b2da792 Mon Sep 17 00:00:00 2001 From: Lexie Date: Mon, 22 Jul 2024 21:46:42 +0000 Subject: [PATCH] fix: seems to work (#1) --- README.md | 15 ++-- package.json | 4 +- src/components/Post.tsx | 70 ++++++++++++------- src/components/Profile.tsx | 2 + ...parseEmbedImage.ts => parseEmbedImages.ts} | 15 ++-- src/routes/getOEmbed.ts | 10 ++- src/routes/getPost.tsx | 2 +- wrangler.toml | 4 +- 8 files changed, 77 insertions(+), 45 deletions(-) rename src/lib/{parseEmbedImage.ts => parseEmbedImages.ts} (76%) diff --git a/README.md b/README.md index 8636459..9f2a811 100644 --- a/README.md +++ b/README.md @@ -1,17 +1,18 @@ -# FixBluesky 🛠️ (Inspired by [FixTweet](https://github.com/FixTweet/FixTweet)) +# VixBluesky 🛠️ (Inspired by [FixTweet](https://github.com/FixTweet/FixTweet)) -Embed Bluesky links in Discord +> [!IMPORTANT] +> This is a fork of [FixBluesky](https://github.com/ItsRauf/FixBluesky) by [@ItsRauf](https://www.github.com/ItsRauf). +> All credits go to them for the original idea and implementation. -## Written With - -[![Tech Stack](https://skillicons.dev/icons?i=ts,html,workers)](https://skillicons.dev) +Embed Bluesky links in Discord. ## How To Use? -#### Simply replace the `k` in `bsky.app` with a `y` +#### Simply append `x` at the end of `bsky.app`. _or you can post the link in Discord and type `s/k/y`_ ## Authors -- [@ItsRauf](https://www.github.com/ItsRauf) +- [@ItsRauf](https://www.github.com/ItsRauf) - Original author +- [@Lexedia](https://www.github.com/Rapougnac) diff --git a/package.json b/package.json index 88a4ff0..c62a4e2 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "deploy": "wrangler deploy --minify src/index.ts" }, "dependencies": { - "@atproto/api": "^0.4.0", - "hono": "^3.3.0" + "@atproto/api": "^0.12.24", + "hono": "^4.5.1" }, "devDependencies": { "@cloudflare/workers-types": "^4.20230628.0", diff --git a/src/components/Post.tsx b/src/components/Post.tsx index 59d8aea..dcede5f 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -1,8 +1,8 @@ -import { AppBskyFeedDefs } from "@atproto/api"; +import { AppBskyEmbedImages, AppBskyFeedDefs } from "@atproto/api"; import { Layout } from "./Layout"; import { OEmbedTypes } from "../routes/getOEmbed"; -import { parseEmbedImage } from "../lib/parseEmbedImage"; +import { parseEmbedImages } from "../lib/parseEmbedImages"; import { parseEmbedDescription } from "../lib/parseEmbedDescription"; interface PostProps { @@ -11,28 +11,46 @@ interface PostProps { appDomain: string; } -export const Post = ({ post, url, appDomain }: PostProps) => ( - - - - - - {!(parseEmbedImage(post) === post.author.avatar) && ( - - )} - - - - - +const Meta = (post: AppBskyFeedDefs.PostView) => ( + <> + + + {/* + */} + ); + +export const Post = ({ post, url, appDomain }: PostProps) => { + const images = parseEmbedImages(post); + const isAuthor = images === post.author.avatar; + + return ( + + + + + {console.log(post)} + + + + {images && typeof images === "string" ? ( + + ) : ( + (images as AppBskyEmbedImages.ViewImage[]).map((img) => ( + + )) + )} + + {!isAuthor && } + + + + ); +}; diff --git a/src/components/Profile.tsx b/src/components/Profile.tsx index b2e9008..0ba5329 100644 --- a/src/components/Profile.tsx +++ b/src/components/Profile.tsx @@ -11,6 +11,7 @@ interface ProfileProps { export const Profile = ({ profile, url, appDomain }: ProfileProps) => ( + ( content={`${profile.displayName} (@${profile.handle})`} /> + = async (c) => { const defaults = { provider_name: "FixBluesky", - provider_url: "https://bsyy.app/", - thumbnail_url: avatar, + provider_url: "https://bskyx.app/", thumbnail_width: 1000, thumbnail_height: 1000, + author_url: 'https://google.com', }; + if (avatar !== undefined) { + (defaults as typeof defaults & { thumbnail_url?: string }).thumbnail_url = + decodeURIComponent(avatar); + } + if (type === OEmbedTypes.Post) { const { replies, reposts, likes } = c.req.query(); + return c.json({ author_name: `🗨️ ${replies} ♻️ ${reposts} 💙 ${likes}`, ...defaults, diff --git a/src/routes/getPost.tsx b/src/routes/getPost.tsx index 1f253d0..ead9e7a 100644 --- a/src/routes/getPost.tsx +++ b/src/routes/getPost.tsx @@ -15,7 +15,7 @@ export const getPost: Handler< message: "Failed to fetch the post!", }); } - // return c.html(genHTML(data.posts[0], c.req.path)); + return c.html(