diff --git a/src/app/api/language-detection/route.ts b/src/app/api/language-detection/route.ts
deleted file mode 100644
index ce658f3e..00000000
--- a/src/app/api/language-detection/route.ts
+++ /dev/null
@@ -1,14 +0,0 @@
-import { detect } from "tinyld";
-
-export async function POST(request: Request) {
- const text = await request.text();
-
- const detectLanguage = async (text = "") => {
- const detected = await detect(text);
- return detected;
- };
-
- return Response.json(await detectLanguage(text), {
- status: 200,
- });
-}
diff --git a/src/components/dataDisplay/gallery/Gallery.tsx b/src/components/dataDisplay/gallery/Gallery.tsx
index 119423ef..fc34dc6b 100644
--- a/src/components/dataDisplay/gallery/Gallery.tsx
+++ b/src/components/dataDisplay/gallery/Gallery.tsx
@@ -43,7 +43,7 @@ export default function Gallery(props: Props) {
break;
}
},
- [handleBackward, handleForward]
+ [handleBackward, handleForward],
);
useEffect(() => {
diff --git a/src/components/dataDisplay/postEmbed/ExternalEmbed.tsx b/src/components/dataDisplay/postEmbed/ExternalEmbed.tsx
index 9d84a19b..351d36fe 100644
--- a/src/components/dataDisplay/postEmbed/ExternalEmbed.tsx
+++ b/src/components/dataDisplay/postEmbed/ExternalEmbed.tsx
@@ -29,7 +29,7 @@ export default function ExternalEmbed(props: Props) {
width={900}
height={500}
priority
- className="border-b-skin-base rounded-t-lg border-b aspect-auto max-h-96 object-cover group-hover:brightness-95"
+ className="border-b-skin-base rounded-t-lg border-b aspect-video max-h-96 object-cover group-hover:brightness-95"
/>
)}
diff --git a/src/components/feedback/altTag/AltTag.tsx b/src/components/feedback/altTag/AltTag.tsx
index cb73d837..9b630225 100644
--- a/src/components/feedback/altTag/AltTag.tsx
+++ b/src/components/feedback/altTag/AltTag.tsx
@@ -3,7 +3,6 @@ import { useState } from "react";
import * as Dialog from "@radix-ui/react-dialog";
import { CgClose } from "react-icons/cg";
import { useClipboard } from "use-clipboard-copy";
-import toast from "react-hot-toast";
import { BiSolidCopy } from "react-icons/bi";
interface Props {
@@ -13,12 +12,7 @@ interface Props {
export default function AltTag(props: Props) {
const { text } = props;
const [showAlt, setShowAlt] = useState(false);
- const clipboard = useClipboard({ copiedTimeout: 3500 });
-
- const handleCopyAltText = () => {
- clipboard.copy(text);
- toast.success("Alt text copied to clipboard", { id: "Copy alt text" });
- };
+ const { copy, copied } = useClipboard({ copiedTimeout: 3500 });
const handleShowAlt = () => {
setShowAlt(!showAlt);
@@ -62,19 +56,20 @@ export default function AltTag(props: Props) {
-
-
-
+
+
+
Alternative text
-
+
{text}
diff --git a/src/components/inputs/editor/BottomEditorBar.tsx b/src/components/inputs/editor/BottomEditorBar.tsx
index a83780c8..c6fa7f13 100644
--- a/src/components/inputs/editor/BottomEditorBar.tsx
+++ b/src/components/inputs/editor/BottomEditorBar.tsx
@@ -77,7 +77,7 @@ export default function BottomEditorBar(props: Props) {
-
+
diff --git a/src/lib/hooks/bsky/feed/usePublishPost.tsx b/src/lib/hooks/bsky/feed/usePublishPost.tsx
index e362a477..43bf29e0 100644
--- a/src/lib/hooks/bsky/feed/usePublishPost.tsx
+++ b/src/lib/hooks/bsky/feed/usePublishPost.tsx
@@ -74,8 +74,8 @@ export default function usePublishPost(props: Props) {
if (languages.length > 0) {
lang = languages;
} else {
- const detectedLanguage = await detectLanguage(richText.text);
- lang = detectedLanguage ?? [];
+ const detectedLanguage = detectLanguage(richText.text);
+ lang = detectedLanguage ? [detectedLanguage] : [];
}
let selfLabels: ComAtprotoLabelDefs.SelfLabels | undefined;
diff --git a/src/lib/utils/text.ts b/src/lib/utils/text.ts
index 51a58bb1..a441f875 100644
--- a/src/lib/utils/text.ts
+++ b/src/lib/utils/text.ts
@@ -1,7 +1,8 @@
import { JSONContent } from "@tiptap/react";
import { ThreadgateSetting } from "../../../types/feed";
import { PostView } from "@atproto/api/dist/client/types/app/bsky/feed/defs";
-import { AppBskyFeedPost, Facet, UnicodeString } from "@atproto/api";
+import { AppBskyFeedPost } from "@atproto/api";
+import { detect } from "tinyld";
export function getHandle(mention: string) {
return mention.slice(1);
@@ -86,24 +87,18 @@ export function jsonToText(json: JSONContent) {
return text;
}
-export async function detectLanguage(text: string) {
+export function detectLanguage(text: string) {
if (text === "") return;
- const res = await fetch(`/api/language-detection`, {
- method: "post",
- body: JSON.stringify({
- text: text,
- }),
- });
+ const language = detect(text);
- const detectedLanguage: string = await res.json();
- return [detectedLanguage.trim()];
+ return language;
}
// TODO: add language prefs to localStorage to use for lang
// the default is English for now
export function getTranslateLink(text: string, lang: string = "en"): string {
return `https://translate.google.com/?sl=auto&tl=${lang}&text=${encodeURIComponent(
- text
+ text,
)}`;
}
@@ -124,4 +119,4 @@ export const replyIncludes = (reply: PostView["record"], term: string) => {
const text = AppBskyFeedPost.isRecord(reply) && reply.text;
if (!text || !text.toLowerCase().includes(term.toLowerCase())) return false;
return true;
-};
\ No newline at end of file
+};