Skip to content

The Open Source DocuSign Alternative.

fix: update og card

Mythied0cedc489fb6
diff --git a/apps/web/src/app/(share)/share/[shareId]/redirect.tsx b/apps/web/src/app/(share)/share/[shareId]/redirect.tsx
index 593d5b1cc..6846975cb 100644
--- a/apps/web/src/app/(share)/share/[shareId]/redirect.tsx
+++ b/apps/web/src/app/(share)/share/[shareId]/redirect.tsx
@@ -1,12 +1,13 @@
'use client';
-import React from 'react';
+import { useEffect } from 'react';
export default function Redirect() {
- React.useEffect(() => {
+ useEffect(() => {
const timer = setTimeout(() => {
window.location.href = 'https://www.documenso.com';
}, 3000);
+
return () => clearTimeout(timer);
}, []);
diff --git a/apps/web/src/app/(signing)/sign/[token]/page.tsx b/apps/web/src/app/(signing)/sign/[token]/page.tsx
index d2c14a524..f3d69b403 100644
--- a/apps/web/src/app/(signing)/sign/[token]/page.tsx
+++ b/apps/web/src/app/(signing)/sign/[token]/page.tsx
@@ -38,10 +38,10 @@ export default async function SigningPage({ params: { token } }: SigningPageProp
}).catch(() => null),
getFieldsForToken({ token }),
getRecipientByToken({ token }).catch(() => null),
- viewedDocument({ token }),
+ viewedDocument({ token }).catch(() => null),
]);
- if (!document || !document.documentData || !recipient) {
+ if (!document || !recipient) {
return notFound();
}
diff --git a/apps/web/src/assets/Caveat-Regular.ttf b/apps/web/src/assets/caveat-regular.ttf
similarity index 100%
rename from apps/web/src/assets/Caveat-Regular.ttf
rename to apps/web/src/assets/caveat-regular.ttf
diff --git a/apps/web/src/assets/inter-bold.ttf b/apps/web/src/assets/inter-bold.ttf
new file mode 100644
index 000000000..8e82c70d1
Binary files /dev/null and b/apps/web/src/assets/inter-bold.ttf differ
diff --git a/apps/web/src/assets/Inter-Regular.ttf b/apps/web/src/assets/inter-regular.ttf
similarity index 100%
rename from apps/web/src/assets/Inter-Regular.ttf
rename to apps/web/src/assets/inter-regular.ttf
diff --git a/apps/web/src/assets/inter-semibold.ttf b/apps/web/src/assets/inter-semibold.ttf
new file mode 100644
index 000000000..c6aeeb16a
Binary files /dev/null and b/apps/web/src/assets/inter-semibold.ttf differ
diff --git a/apps/web/src/assets/og-share-frame.png b/apps/web/src/assets/og-share-frame.png
new file mode 100644
index 000000000..72bf7dd96
Binary files /dev/null and b/apps/web/src/assets/og-share-frame.png differ
diff --git a/apps/web/src/pages/api/share-og/index.tsx b/apps/web/src/pages/api/share-og/index.tsx
index 28abbce36..772196fbd 100644
--- a/apps/web/src/pages/api/share-og/index.tsx
+++ b/apps/web/src/pages/api/share-og/index.tsx
@@ -1,47 +1,71 @@
import { ImageResponse, NextRequest } from 'next/server';
+import { cn } from '@documenso/ui/lib/utils';
+
export const config = {
runtime: 'edge',
};
+const CARD_OFFSET_TOP = 152;
+const CARD_OFFSET_LEFT = 350;
+const CARD_WIDTH = 500;
+const CARD_HEIGHT = 250;
+
export default async function handler(req: NextRequest) {
const { searchParams } = new URL(req.url);
+
const signature = searchParams.get('signature') || 'Timur';
- const [imageData, CaveatFontData, InterFontData] = await Promise.all([
- fetch(new URL('../../../assets/background-pattern-og.png', import.meta.url)).then((res) =>
+ const [interSemiBold, interRegular, caveatRegular, shareFrameImage] = await Promise.all([
+ fetch(new URL('./../../../assets/inter-semibold.ttf', import.meta.url)).then(async (res) =>
res.arrayBuffer(),
),
- fetch(new URL('../../../assets/Caveat-Regular.ttf', import.meta.url)).then((res) =>
+ fetch(new URL('./../../../assets/inter-regular.ttf', import.meta.url)).then(async (res) =>
res.arrayBuffer(),
),
- fetch(new URL('../../../assets/Inter-Regular.ttf', import.meta.url)).then((res) =>
+ fetch(new URL('./../../../assets/caveat-regular.ttf', import.meta.url)).then(async (res) =>
+ res.arrayBuffer(),
+ ),
+ fetch(new URL('./../../../assets/og-share-frame.png', import.meta.url)).then(async (res) =>
res.arrayBuffer(),
),
]);
return new ImageResponse(
(
- <div
- style={{
- height: '100%',
- width: '100%',
- display: 'flex',
- flexDirection: 'column',
- alignItems: 'center',
- justifyContent: 'center',
- background: `url('data:image/png;base64,${Buffer.from(
- imageData as unknown as string,
- ).toString('base64')}')`,
- backgroundSize: '1200px 630px',
- backgroundPositionY: '0%',
- }}
- >
- <div tw="flex px-20 py-12 bg-gray-100 rounded-md border-solid border-4 border-zinc-200 shadow-md">
- <div tw="text-[#64748B99] text-7xl">{signature}</div>
- </div>
- <div tw="text-black text-3xl my-8 text-gray-600" style={{ fontFamily: 'Inter' }}>
- You signed with Documenso
+ <div tw="relative flex h-full w-full">
+ {/* @ts-expect-error Lack of typing from ImageResponse */}
+ <img src={shareFrameImage} alt="og-share-frame" tw="absolute inset-0 w-full h-full" />
+
+ <p
+ tw="absolute py-6 px-12 -mt-2 flex items-center justify-center text-center"
+ style={{
+ fontFamily: 'Caveat',
+ fontSize: `${Math.max(Math.min((CARD_WIDTH * 1.5) / signature.length, 80), 36)}px`,
+ top: `${CARD_OFFSET_TOP}px`,
+ left: `${CARD_OFFSET_LEFT}px`,
+ width: `${CARD_WIDTH}px`,
+ height: `${CARD_HEIGHT}px`,
+ }}
+ >
+ {signature}
+ </p>
+
+ <div
+ tw="absolute absolute flex flex-col items-center justify-center pt-2.5 w-full"
+ style={{
+ top: `${CARD_OFFSET_TOP + CARD_HEIGHT}px`,
+ }}
+ >
+ <h2
+ tw="text-2xl text-slate-900/60"
+ style={{
+ fontFamily: 'Inter',
+ fontWeight: 600,
+ }}
+ >
+ I just signed with Documenso
+ </h2>
</div>
</div>
),
@@ -51,13 +75,20 @@ export default async function handler(req: NextRequest) {
fonts: [
{
name: 'Caveat',
- data: CaveatFontData,
+ data: caveatRegular,
style: 'italic',
},
{
name: 'Inter',
- data: InterFontData,
+ data: interRegular,
+ style: 'normal',
+ weight: 400,
+ },
+ {
+ name: 'Inter',
+ data: interSemiBold,
style: 'normal',
+ weight: 600,
},
],
},