+
+ }
+ onClick={() => {
+ modal?.swap();
+ }}
+ />
+
+
+ );
+}
diff --git a/components/TextRendering/Video.tsx b/components/TextRendering/Video.tsx
new file mode 100644
index 0000000..bbaacea
--- /dev/null
+++ b/components/TextRendering/Video.tsx
@@ -0,0 +1,24 @@
+import ReactPlayer from "react-player";
+import { cn } from "@/lib/utils";
+export default function ImageUrl({
+ url,
+ className,
+}: {
+ url: string;
+ className?: string;
+}) {
+ return (
+
+
+
+ );
+}
diff --git a/components/TextRendering/index.tsx b/components/TextRendering/index.tsx
index 31bad80..3b20ca0 100644
--- a/components/TextRendering/index.tsx
+++ b/components/TextRendering/index.tsx
@@ -1,7 +1,14 @@
-import { cleanUrl } from "@/lib/utils";
+import { cleanUrl, getFirstSubdomain } from "@/lib/utils";
import Link from "next/link";
+import dynamic from "next/dynamic";
import ProfileMention from "./ProfileMention";
import EventMention from "./EventMention";
+const ImageUrl = dynamic(() => import("./Image"), {
+ ssr: false,
+});
+const VideoUrl = dynamic(() => import("./Video"), {
+ ssr: false,
+});
const urlRegex =
/(https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9()@:%_\+.~#?&//=]*))/g;
@@ -27,17 +34,37 @@ const RenderText = ({ text }: { text?: string }) => {
Elements.push(jsxElement);
let specialElement;
if (specialValuesArray?.length && specialValuesArray.length > index) {
- if (specialValuesArray[index]?.match(urlRegex)) {
- specialElement = (
-
- {cleanUrl(specialValuesArray[index])}
-
- );
+ const currentValue = specialValuesArray[index];
+ if (currentValue?.match(urlRegex)) {
+ console.log("First zSub", getFirstSubdomain(currentValue));
+ const subdomain = getFirstSubdomain(currentValue);
+ if (!subdomain || subdomain === "www") {
+ specialElement = (
+
+ {cleanUrl(currentValue)}
+
+ );
+ } else if (subdomain === "i" || subdomain === "image") {
+ specialElement =
;
+ } else if (["v", "video"].includes(subdomain)) {
+ specialElement =
;
+ } else {
+ specialElement = (
+
+ {cleanUrl(currentValue)}
+
+ );
+ }
// specialElement =
;
// specialElement =
{cleanUrl(specialValuesArray[index])};
} else if (specialValuesArray[index]?.match(hashtagRegex)) {
diff --git a/lib/utils/index.ts b/lib/utils/index.ts
index 7d302e7..e91d274 100644
--- a/lib/utils/index.ts
+++ b/lib/utils/index.ts
@@ -21,6 +21,16 @@ export function cleanUrl(url?: string) {
}
return url;
}
+export function getFirstSubdomain(url: string): string | null {
+ // Use a regular expression to extract the first subdomain
+ const subdomainMatch = url.match(/^(https?:\/\/)?([^.]+)\./i);
+
+ if (subdomainMatch && subdomainMatch[2]) {
+ return subdomainMatch[2];
+ }
+
+ return null;
+}
export function truncateText(text: string, size?: number) {
let length = size ?? 5;