Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 20 additions & 37 deletions components/view/custom-metatag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,66 +11,49 @@ const CustomMetatag = ({
title: string | null;
description: string | null;
imageUrl: string | null;
url: string;
url: string | null;
}) => {
return (
<Head>
{/* meta URL */}
{url && (
<>
<link rel="canonical" href={url} key="canonical" />
<meta property="og:url" content={url} key="og-url" />
</>
)}
{title && (

{/* meta title */}
{enableBranding && title && (
<>
<title>{title}</title>
<meta property="og:title" content={title} key="og-title" />
<meta name="twitter:title" content={title} key="tw-title" />
</>
)}
{!enableBranding && (

{/* meta description */}
{enableBranding && description && (
<>
<meta name="description" content={description} key="description" />
<meta
property="og:image"
// content={`/api/og?title=${title ?? ""}`}
content="https://www.papermark.io/_static/meta-image.png"
key="og-image"
property="og:description"
content={description}
key="og-description"
/>
<meta
name="twitter:image"
// content={`/api/og?title=${title ?? ""}`}
content="https://www.papermark.io/_static/meta-image.png"
key="tw-image"
name="twitter:description"
content={description}
key="tw-description"
/>
</>
)}
{enableBranding && (

{/* meta image */}
{enableBranding && imageUrl && (
<>
{description ? (
<>
<meta
name="description"
content={description}
key="description"
/>
<meta
property="og:description"
content={description}
key="og-description"
/>
<meta
name="twitter:description"
content={description}
key="tw-description"
/>
</>
) : null}
{imageUrl ? (
<>
<meta property="og:image" content={imageUrl} key="og-image" />
<meta name="twitter:image" content={imageUrl} key="tw-image" />
</>
) : null}
<meta property="og:image" content={imageUrl} key="og-image" />
<meta name="twitter:image" content={imageUrl} key="tw-image" />
</>
)}
</Head>
Expand Down
91 changes: 56 additions & 35 deletions pages/view/[linkId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
metaTitle: link.metaTitle,
metaDescription: link.metaDescription,
metaImage: link.metaImage,
metaUrl: `https://www.papermark.io/view/${linkId}`,
},
showPoweredByBanner: teamPlan === "free",
},
Expand Down Expand Up @@ -134,6 +135,7 @@ export const getStaticProps = async (context: GetStaticPropsContext) => {
metaTitle: link.metaTitle,
metaDescription: link.metaDescription,
metaImage: link.metaImage,
metaUrl: `https://www.papermark.io/view/${linkId}`,
},
showPoweredByBanner: false,
},
Expand Down Expand Up @@ -169,7 +171,8 @@ export default function ViewPage({
metaTitle: string | null;
metaDescription: string | null;
metaImage: string | null;
} | null;
metaUrl: string | null;
};
showPoweredByBanner: boolean;
}) {
const router = useRouter();
Expand All @@ -195,13 +198,15 @@ export default function ViewPage({
return (
<>
<CustomMetatag
enableBranding={meta?.enableCustomMetatag ?? false}
enableBranding={meta.enableCustomMetatag ?? false}
title={
meta?.metaTitle ?? link?.document?.name ?? "Papermark Document"
meta.metaTitle ??
`${link?.document?.name} | Powered by Papermark` ??
"Document powered by Papermark"
}
description={meta?.metaDescription ?? null}
imageUrl={meta?.metaImage ?? null}
url={`https://www.papermark.io/view/${router.query.linkId}`}
description={meta.metaDescription ?? null}
imageUrl={meta.metaImage ?? null}
url={meta.metaUrl ?? ""}
/>
<div className="flex h-screen items-center justify-center">
<LoadingSpinner className="h-20 w-20" />
Expand Down Expand Up @@ -234,17 +239,19 @@ export default function ViewPage({
);
}

const { enableCustomMetatag, metaTitle, metaDescription, metaImage } = link;

if (emailProtected || linkPassword) {
return (
<>
<CustomMetatag
enableBranding={enableCustomMetatag ?? false}
title={metaTitle ?? link.document.name}
description={metaDescription}
imageUrl={metaImage}
url={`https://www.papermark.io/view/${router.query.linkId}`}
enableBranding={meta.enableCustomMetatag ?? false}
title={
meta.metaTitle ??
`${link?.document?.name} | Powered by Papermark` ??
"Document powered by Papermark"
}
description={meta.metaDescription ?? null}
imageUrl={meta.metaImage ?? null}
url={meta.metaUrl ?? ""}
/>
<DocumentView
link={link}
Expand All @@ -264,11 +271,15 @@ export default function ViewPage({
return (
<>
<CustomMetatag
enableBranding={enableCustomMetatag ?? false}
title={metaTitle ?? link.document.name}
description={metaDescription}
imageUrl={metaImage}
url={`https://www.papermark.io/view/${router.query.linkId}`}
enableBranding={meta.enableCustomMetatag ?? false}
title={
meta.metaTitle ??
`${link?.document?.name} | Powered by Papermark` ??
"Document powered by Papermark"
}
description={meta.metaDescription ?? null}
imageUrl={meta.metaImage ?? null}
url={meta.metaUrl ?? ""}
/>
<DocumentView
link={link}
Expand All @@ -289,11 +300,15 @@ export default function ViewPage({
return (
<>
<CustomMetatag
enableBranding={meta?.enableCustomMetatag ?? false}
title={meta?.metaTitle ?? link?.dataroom.name ?? "Dataroom"}
description={meta?.metaDescription ?? null}
imageUrl={meta?.metaImage ?? null}
url={`https://www.papermark.io/view/${router.query.linkId}`}
enableBranding={meta.enableCustomMetatag ?? false}
title={
meta.metaTitle ??
`${link?.dataroom?.name} | Powered by Papermark` ??
"Dataroom powered by Papermark"
}
description={meta.metaDescription ?? null}
imageUrl={meta.metaImage ?? null}
url={meta.metaUrl ?? ""}
/>
<div className="flex h-screen items-center justify-center">
<LoadingSpinner className="h-20 w-20" />
Expand Down Expand Up @@ -326,17 +341,19 @@ export default function ViewPage({
);
}

const { enableCustomMetatag, metaTitle, metaDescription, metaImage } = link;

if (emailProtected || linkPassword) {
return (
<>
<CustomMetatag
enableBranding={enableCustomMetatag ?? false}
title={metaTitle}
description={metaDescription}
imageUrl={metaImage}
url={`https://www.papermark.io/view/${router.query.linkId}`}
enableBranding={meta.enableCustomMetatag ?? false}
title={
meta.metaTitle ??
`${link?.dataroom?.name} | Powered by Papermark` ??
"Dataroom powered by Papermark"
}
description={meta.metaDescription ?? null}
imageUrl={meta.metaImage ?? null}
url={meta.metaUrl ?? ""}
/>
<DataroomView
link={link}
Expand All @@ -354,11 +371,15 @@ export default function ViewPage({
return (
<>
<CustomMetatag
enableBranding={enableCustomMetatag ?? false}
title={metaTitle}
description={metaDescription}
imageUrl={metaImage}
url={`https://www.papermark.io/view/${router.query.linkId}`}
enableBranding={meta.enableCustomMetatag ?? false}
title={
meta.metaTitle ??
`${link?.dataroom?.name} | Powered by Papermark` ??
"Dataroom powered by Papermark"
}
description={meta.metaDescription ?? null}
imageUrl={meta.metaImage ?? null}
url={meta.metaUrl ?? ""}
/>
<DataroomView
link={link}
Expand Down
Loading