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 root domain bug, removed duplicate code

Steven Teye74cfd77263f
diff --git a/app/[domain]/page.tsx b/app/[domain]/page.tsx
index 39c10c2cae..452cfc291e 100644
--- a/app/[domain]/page.tsx
+++ b/app/[domain]/page.tsx
@@ -32,6 +32,9 @@ export async function generateStaticParams() {
where: {
verified: true,
target: null,
+ NOT: {
+ slug: "dub.sh",
+ },
},
select: {
slug: true,
diff --git a/app/[domain]/stats/[key]/page.tsx b/app/[domain]/stats/[key]/page.tsx
index 93b9aa6500..7c2e8ba3bf 100644
--- a/app/[domain]/stats/[key]/page.tsx
+++ b/app/[domain]/stats/[key]/page.tsx
@@ -24,6 +24,15 @@ export async function generateMetadata({
});
}
+export async function generateStaticParams() {
+ return [
+ {
+ domain: "dub.sh",
+ key: "github",
+ },
+ ];
+}
+
export default async function StatsPage({
params,
}: {
diff --git a/app/dub.sh/page.tsx b/app/dub.sh/page.tsx
index 7043f863c9..5bd14bcf5c 100644
--- a/app/dub.sh/page.tsx
+++ b/app/dub.sh/page.tsx
@@ -4,7 +4,6 @@ import Stats from "#/ui/home/stats";
import Features from "#/ui/home/features";
import Hero from "#/ui/home/hero";
import Logos from "#/ui/home/logos";
-import Pricing from "#/ui/home/pricing";
import OSS from "#/ui/home/oss";
import Testimonials from "#/ui/home/testimonials";
import { constructMetadata } from "#/lib/utils";
diff --git a/app/dub.sh/stats/[key]/page.tsx b/app/dub.sh/stats/[key]/page.tsx
deleted file mode 100644
index 1e5cbee644..0000000000
--- a/app/dub.sh/stats/[key]/page.tsx
+++ /dev/null
@@ -1,54 +0,0 @@
-import { notFound } from "next/navigation";
-import { getLinkViaEdge } from "#/lib/planetscale";
-import Stats from "#/ui/stats";
-import { Suspense } from "react";
-import { Metadata } from "next";
-import { constructMetadata } from "#/lib/utils";
-
-export const runtime = "edge";
-
-export async function generateMetadata({
- params,
-}: {
- params: { key: string };
-}): Promise<Metadata | undefined> {
- const data = await getLinkViaEdge("dub.sh", params.key);
-
- if (!data || !data.publicStats) {
- return;
- }
-
- return constructMetadata({
- title: `Stats for dub.sh/${params.key} - Dub`,
- description: `Stats page for dub.sh/${params.key}, which redirects to ${data.url}.`,
- image: `https://dub.sh/api/og/stats?domain=dub.sh&key=${params.key}`,
- });
-}
-
-export async function generateStaticParams() {
- return [
- {
- key: "github",
- },
- ];
-}
-
-export default async function StatsPage({
- params,
-}: {
- params: { key: string };
-}) {
- const data = await getLinkViaEdge("dub.sh", params.key);
-
- if (!data || !data.publicStats) {
- notFound();
- }
-
- return (
- <div className="bg-gray-50">
- <Suspense fallback={<div className="h-screen w-full bg-gray-50" />}>
- <Stats staticDomain="dub.sh" />
- </Suspense>
- </div>
- );
-}
diff --git a/lib/middleware/root.ts b/lib/middleware/root.ts
index 144d121667..9dc73a5363 100644
--- a/lib/middleware/root.ts
+++ b/lib/middleware/root.ts
@@ -12,8 +12,6 @@ export default async function RootMiddleware(
) {
const { domain } = parse(req);
- console.log("domain", domain, "isHomeHostname", isHomeHostname(domain));
-
if (!domain) {
return NextResponse.next();
}
diff --git a/lib/middleware/utils.ts b/lib/middleware/utils.ts
index a5c8e56935..ce0b48baea 100644
--- a/lib/middleware/utils.ts
+++ b/lib/middleware/utils.ts
@@ -13,7 +13,6 @@ export const parse = (req: NextRequest) => {
const key = decodeURIComponent(path.split("/")[1]); // key is the first part of the path (e.g. dub.sh/stats/github -> stats)
const fullKey = decodeURIComponent(path.slice(1)); // fullKey is the full path without the first slash (to account for multi-level subpaths, e.g. dub.sh/github/repo -> github/repo)
- console.log({ domain, path, key, fullKey });
return { domain, path, key, fullKey };
};