Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

fix #450, add custom favicon for password pages

Steven Teya1adde2edbd5
diff --git a/apps/web/app/protected/[domain]/[key]/page.tsx b/apps/web/app/protected/[domain]/[key]/page.tsx
index 63ba6f39b9..3096059985 100644
--- a/apps/web/app/protected/[domain]/[key]/page.tsx
+++ b/apps/web/app/protected/[domain]/[key]/page.tsx
@@ -9,12 +9,47 @@ const description =
"This link is password protected. Please enter the password to view it.";
const image = "https://dub.co/_static/password-protected.png";
-export const metadata = constructMetadata({
- title,
- description,
- image,
- noIndex: true,
-});
+export async function generateMetadata({
+ params,
+}: {
+ params: { domain: string; key: string };
+}) {
+ const domain = params.domain;
+ const key = decodeURIComponent(params.key);
+
+ const link = await prisma.link.findUnique({
+ where: {
+ domain_key: {
+ domain,
+ key,
+ },
+ },
+ select: {
+ project: {
+ select: {
+ logo: true,
+ plan: true,
+ },
+ },
+ },
+ });
+
+ if (!link) {
+ notFound();
+ }
+
+ return constructMetadata({
+ title,
+ description,
+ image,
+ ...(domain !== "dub.sh" &&
+ link.project?.plan !== "free" &&
+ link.project?.logo && {
+ icons: link.project.logo,
+ }),
+ noIndex: true,
+ });
+}
export async function generateStaticParams() {
const passwordProtectedLinks = await prisma.link.findMany({
diff --git a/apps/web/lib/edge-config.ts b/apps/web/lib/edge-config.ts
index bf1b780b03..6b3a025034 100644
--- a/apps/web/lib/edge-config.ts
+++ b/apps/web/lib/edge-config.ts
@@ -71,7 +71,7 @@ export const isReservedKey = async (key: string) => {
"metatags",
"terms",
"privacy",
- ];
+ ].includes(key);
}
let reservedKey;
try {