Skip to content

Papermark is the open-source DocSend alternative and secure data rooms with built-in analytics and custom domains.

feat: add powered by button

Marc Seitz2b644e1a9146
diff --git a/components/view/PagesViewer.tsx b/components/view/PagesViewer.tsx
index 78d30fbe..e70fdcf7 100644
--- a/components/view/PagesViewer.tsx
+++ b/components/view/PagesViewer.tsx
@@ -7,6 +7,7 @@ import Nav from "./nav";
import Toolbar from "./toolbar";
import { Brand, DataroomBrand } from "@prisma/client";
import { useRouter } from "next/router";
+import { PoweredBy } from "./powered-by";
const DEFAULT_PRELOADED_IMAGES_NUM = 10;
@@ -22,6 +23,7 @@ export default function PagesViewer({
brand,
dataroomId,
setDocumentData,
+ showPoweredByBanner,
}: {
pages: { file: string; pageNumber: string; embeddedLinks: string[] }[];
linkId: string;
@@ -34,6 +36,7 @@ export default function PagesViewer({
brand?: Brand | DataroomBrand;
dataroomId?: string;
setDocumentData?: (data: any) => void;
+ showPoweredByBanner?: boolean;
}) {
const router = useRouter();
const numPages = pages.length;
@@ -251,6 +254,7 @@ export default function PagesViewer({
{feedbackEnabled ? (
<Toolbar viewId={viewId} pageNumber={pageNumber} />
) : null}
+ {showPoweredByBanner ? <PoweredBy linkId={linkId} /> : null}
</div>
</>
);
diff --git a/components/view/document-view.tsx b/components/view/document-view.tsx
index bd2924da..caa16a5f 100644
--- a/components/view/document-view.tsx
+++ b/components/view/document-view.tsx
@@ -29,6 +29,7 @@ export default function DocumentView({
brand,
token,
verifiedEmail,
+ showPoweredByBanner,
}: {
link: LinkWithDocument;
userEmail: string | null | undefined;
@@ -41,6 +42,7 @@ export default function DocumentView({
brand?: Brand;
token?: string;
verifiedEmail?: string;
+ showPoweredByBanner?: boolean;
}) {
const { document, emailProtected, password: linkPassword } = link;
@@ -173,6 +175,7 @@ export default function DocumentView({
viewData={viewData}
notionData={notionData}
brand={brand}
+ showPoweredByBanner={showPoweredByBanner}
/>
) : (
<div className="h-screen flex items-center justify-center">
diff --git a/components/view/nav.tsx b/components/view/nav.tsx
index ab0dcbcb..59f48c4d 100644
--- a/components/view/nav.tsx
+++ b/components/view/nav.tsx
@@ -85,7 +85,7 @@ export default function Nav({
/>
) : (
<Link
- href="https://www.papermark.io"
+ href={`https://www.papermark.io?utm_campaign=navbar&utm_medium=navbar&utm_source=papermark-${linkId}`}
target="_blank"
className="text-2xl font-bold tracking-tighter text-white"
>
diff --git a/components/view/powered-by.tsx b/components/view/powered-by.tsx
new file mode 100644
index 00000000..de53cb4a
--- /dev/null
+++ b/components/view/powered-by.tsx
@@ -0,0 +1,25 @@
+export const PoweredBy = ({ linkId }: { linkId: string }) => {
+ return (
+ <div
+ className="flex flex-col absolute bottom-0 left-0 right-0"
+ style={{ insetBlockEnd: "0px", insetInline: "0px" }}
+ >
+ <div className="flex w-full flex-col">
+ <div className="flex w-full justify-start flex-row-reverse p-6">
+ <div className="z-20 flex justify-end w-auto rounded-md whitespace-nowrap pointer-events-auto relative min-h-8 bg-black text-white items-center ring-1 ring-white/40 hover:ring-white/90">
+ <a
+ href={`https://www.papermark.io?utm_campaign=poweredby&utm_medium=poweredby&utm_source=papermark-${linkId}`}
+ target="_blank"
+ rel="noopener noreferrer"
+ className="rounded-sm text-sm "
+ style={{ paddingInlineStart: "12px", paddingInlineEnd: "12px" }}
+ >
+ Share docs via{" "}
+ <span className="font-semibold tracking-tighter">Papermark</span>
+ </a>
+ </div>
+ </div>
+ </div>
+ </div>
+ );
+};
diff --git a/components/view/view-data.tsx b/components/view/view-data.tsx
index fccabda6..75c6c2fc 100644
--- a/components/view/view-data.tsx
+++ b/components/view/view-data.tsx
@@ -11,6 +11,7 @@ export default function ViewData({
link,
notionData,
brand,
+ showPoweredByBanner,
}: {
viewData: DEFAULT_DOCUMENT_VIEW_TYPE;
link: LinkWithDocument;
@@ -19,6 +20,7 @@ export default function ViewData({
recordMap: ExtendedRecordMap | null;
};
brand?: Brand;
+ showPoweredByBanner?: boolean;
}) {
const { document } = link;
return notionData?.recordMap ? (
@@ -42,6 +44,7 @@ export default function ViewData({
feedbackEnabled={link.enableFeedback!}
versionNumber={document.versions[0].versionNumber}
brand={brand}
+ showPoweredByBanner={showPoweredByBanner}
/>
) : (
<PDFViewer
diff --git a/lib/types.ts b/lib/types.ts
index 00494a8d..da332e81 100644
--- a/lib/types.ts
+++ b/lib/types.ts
@@ -47,11 +47,10 @@ export interface LinkWithDocument extends Link {
type: string;
hasPages: boolean;
file: string;
- }[] & {
- team?: {
- plan: string;
- };
- };
+ }[];
+ team: {
+ plan: string;
+ } | null;
};
}
diff --git a/pages/api/links/[id]/index.ts b/pages/api/links/[id]/index.ts
index 3517a4ed..f979e3ce 100644
--- a/pages/api/links/[id]/index.ts
+++ b/pages/api/links/[id]/index.ts
@@ -39,6 +39,11 @@ export default async function handle(
assistantEnabled: true,
teamId: true,
ownerId: true,
+ team: {
+ select: {
+ plan: true,
+ },
+ },
versions: {
where: { isPrimary: true },
select: {
diff --git a/pages/view/[linkId]/index.tsx b/pages/view/[linkId]/index.tsx
index c5788370..47a3d9d7 100644
--- a/pages/view/[linkId]/index.tsx
+++ b/pages/view/[linkId]/index.tsx
@@ -50,13 +50,16 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
recordMap = await notion.getPage(pageId);
}
+ const { team, ...linkDocument } = link.document;
+ const teamPlan = team?.plan || "free";
+
return {
props: {
// return link without file and type to avoid sending the file to the client
link: {
...link,
document: {
- ...link.document,
+ ...linkDocument,
versions: [versionWithoutTypeAndFile],
},
},
@@ -71,6 +74,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
metaImage: link.metaImage,
},
brand, // pass brand to the client
+ showPoweredByBanner: teamPlan === "free",
},
revalidate: brand ? 10 : false,
};
@@ -88,6 +92,7 @@ export default function ViewPage({
notionData,
meta,
brand,
+ showPoweredByBanner,
}: {
link: LinkWithDocument;
notionData: {
@@ -101,6 +106,7 @@ export default function ViewPage({
metaImage: string | null;
} | null;
brand?: Brand;
+ showPoweredByBanner: boolean;
}) {
const router = useRouter();
const { token, email: verifiedEmail } = router.query as {
@@ -184,6 +190,7 @@ export default function ViewPage({
brand={brand}
token={token}
verifiedEmail={verifiedEmail}
+ showPoweredByBanner={showPoweredByBanner}
/>
</>
);
@@ -212,6 +219,7 @@ export default function ViewPage({
isProtected={false}
notionData={notionData}
brand={brand}
+ showPoweredByBanner={showPoweredByBanner}
/>
</>
);