diff --git a/apps/web/src/app/(share)/share/[shareId]/page.tsx b/apps/web/src/app/(share)/share/[shareId]/page.tsx new file mode 100644 index 000000000..6d6b2c436 --- /dev/null +++ b/apps/web/src/app/(share)/share/[shareId]/page.tsx @@ -0,0 +1,48 @@ +import React from 'react'; + +import { Metadata } from 'next'; +import { notFound } from 'next/navigation'; + +import { getSharingId } from '@documenso/lib/server-only/share/get-share-id'; + +type MetadataProps = { + params: { shareId: string }; +}; + +export async function generateMetadata({ params }: MetadataProps): Promise { + const id = params.shareId; + const share = await getSharingId({ shareId: id }); + const signature = share?.recipent.name || share?.recipent.email; + + return { + title: 'Documenso - Share', + openGraph: { + images: [`/api/share-og?signature=${signature}`], + }, + }; +} + +export type SharePageProps = { + params: { + shareId?: string; + }; +}; + +export default async function SharePage({ params: { shareId } }: SharePageProps) { + if (!shareId) { + return notFound(); + } + + const share = await getSharingId({ shareId }); + + if (!share) { + return notFound(); + } + + return ( +
+

Share Page

+

Redirecting...

+
+ ); +} diff --git a/apps/web/src/app/(share)/share/[shortId]/page.tsx b/apps/web/src/app/(share)/share/[shortId]/page.tsx deleted file mode 100644 index 0c6fb0897..000000000 --- a/apps/web/src/app/(share)/share/[shortId]/page.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import React from 'react'; - -export type SharePageProps = { - params: { - shortId?: string; - }; -}; - -export default async function SharePage({ params: { shortId } }: SharePageProps) { - console.log(shortId); - - return ( -
-

Share Page

-
- ); -} diff --git a/packages/lib/server-only/share/get-share-id.ts b/packages/lib/server-only/share/get-share-id.ts new file mode 100644 index 000000000..1805826c5 --- /dev/null +++ b/packages/lib/server-only/share/get-share-id.ts @@ -0,0 +1,18 @@ +import { prisma } from '@documenso/prisma'; + +export interface GetSharingIdOptions { + shareId: string; +} + +export const getSharingId = async ({ shareId }: GetSharingIdOptions) => { + const result = await prisma.share.findUnique({ + where: { + link: shareId, + }, + include: { + recipent: true, + }, + }); + + return result; +};