Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

feat: Copy link to clipboard

Richie McIlroye9b787ea85e7
diff --git a/apps/web/app/share/[videoId]/_components/ShareHeader.tsx b/apps/web/app/share/[videoId]/_components/ShareHeader.tsx
index d04f5d1a9..118a8ac94 100644
--- a/apps/web/app/share/[videoId]/_components/ShareHeader.tsx
+++ b/apps/web/app/share/[videoId]/_components/ShareHeader.tsx
@@ -5,6 +5,7 @@ import { userSelectProps } from "@cap/database/auth/session";
import { useRouter } from "next/navigation";
import { useState } from "react";
import { toast } from "react-hot-toast";
+import { LinkIcon } from "lucide-react";
export const ShareHeader = ({
data,
@@ -81,6 +82,23 @@ export const ShareHeader = ({
{moment(data.createdAt).fromNow()}
</p>
</div>
+ <div>
+ <button
+ className="bg-white p-2 w-8 h-8 rounded-lg flex items-center justify-center border hover:border-primary-3 transition-all"
+ onClick={() => {
+ if (process.env.NEXT_PUBLIC_IS_CAP) {
+ navigator.clipboard.writeText(`https://cap.link/${data.id}`);
+ } else {
+ navigator.clipboard.writeText(
+ `${process.env.NEXT_PUBLIC_URL}/share/${data.id}`
+ );
+ }
+ toast.success("Link copied to clipboard!");
+ }}
+ >
+ <LinkIcon className="w-5 h-5" />
+ </button>
+ </div>
</div>
{user !== null && (
<div className="hidden md:flex">
diff --git a/apps/web/next.config.mjs b/apps/web/next.config.mjs
index c31fe593d..0a4e5d1a9 100644
--- a/apps/web/next.config.mjs
+++ b/apps/web/next.config.mjs
@@ -50,7 +50,7 @@ const nextConfig = {
value: "cap.link",
},
],
- destination: "/share/:path*",
+ destination: "https://cap.so/share/:path*",
},
{
source: "/r/:path*",
diff --git a/packages/database/auth/auth-options.ts b/packages/database/auth/auth-options.ts
index 426ec2449..c42fc5fe8 100644
--- a/packages/database/auth/auth-options.ts
+++ b/packages/database/auth/auth-options.ts
@@ -54,6 +54,9 @@ export const authOptions: NextAuthOptions = {
return session;
},
+ async redirect({ url, baseUrl }) {
+ return baseUrl;
+ },
async jwt({ token, user }) {
const [dbUser] = await db
.select()