The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Fixed placeholder pages, lazyOnLoad script, fixed onboarding UX confusion
Steven Teya27833d9ebef
diff --git a/components/app/add-link-modal.tsx b/components/app/add-link-modal.tsxindex db2aba2505..caab9759a6 100644--- a/components/app/add-link-modal.tsx+++ b/components/app/add-link-modal.tsx@@ -324,7 +324,7 @@ start adding links.") : (<buttononClick={() => setShowAddLinkModal(true)}- className="text-gray-500 hover:border-black active:scale-95 font-medium text-sm px-5 py-2 border rounded-md border-gray-200 transition-all duration-75"+ className="text-white hover:text-black bg-black hover:bg-white active:scale-95 font-medium text-sm px-5 py-2 border rounded-md border-black transition-all duration-75">Add</button>diff --git a/components/app/no-projects-placeholder.tsx b/components/app/no-projects-placeholder.tsxindex 3dcef8ec2c..f4d6884aea 100644--- a/components/app/no-projects-placeholder.tsx+++ b/components/app/no-projects-placeholder.tsx@@ -1,4 +1,5 @@import BlurImage from "@/components/shared/blur-image";+import Link from "next/link";export default function NoProjectsPlaceholder({setShowAddProjectModal,@@ -19,10 +20,15 @@ export default function NoProjectsPlaceholder({/><buttononClick={() => setShowAddProjectModal(true)}- className="text-gray-500 hover:border-black active:scale-95 font-medium text-sm px-5 py-2 border rounded-md border-gray-200 transition-all duration-75 z-10"+ className="text-white hover:text-black bg-black hover:bg-white active:scale-95 font-medium text-sm px-10 py-2 border rounded-md border-black transition-all duration-75 z-10">Create a project</button>+ <Link href="/links">+ <a className="text-gray-500 hover:text-gray-800 active:scale-95 mt-3 font-medium text-sm transition-all">+ Add a Dub.sh link instead+ </a>+ </Link></div>);}diff --git a/components/home/globe.tsx b/components/home/globe.tsxindex 6a804f3c33..5b5461f04f 100644--- a/components/home/globe.tsx+++ b/components/home/globe.tsx@@ -1,7 +1,5 @@import { useCallback, useEffect, useRef, useState } from "react";import Link from "next/link";-import { useRouter } from "next/router";-import { useStatsModal } from "@/components/stats/stats-modal";import createGlobe from "cobe";import { useSpring } from "react-spring";import useSWR from "swr";@@ -14,13 +12,9 @@ interface MarkerProps {size: number;}-export default function Globe() {- const router = useRouter();- const { key: stats } = router.query;- const { setShowStatsModal } = useStatsModal();-+export default function Globe({ hostname }: { hostname?: string }) {const { data: markers } = useSWR<MarkerProps[]>(- "/api/edge/coordinates",+ `/api/edge/coordinates${hostname ? `?hostname=${hostname}` : ""}`,fetcher);@@ -83,7 +77,7 @@ export default function Globe() {initial={{ scale: 0 }}animate={{ scale: 1 }}exit={{ scale: 0 }}- className="group absolute left-0 right-0 mx-auto z-10 max-w-sm px-5 py-7 rounded-md bg-white border border-gray-200 shadow-md bg-opacity-90 backdrop-blur-md"+ className="group absolute left-0 right-0 mx-auto z-10 max-w-sm px-5 py-4 sm:py-7 rounded-md bg-white border border-gray-200 shadow-md bg-opacity-90 backdrop-blur-md"><buttonclassName="visible sm:invisible group-hover:visible absolute top-0 right-0 p-1 m-3 rounded-full float-right group hover:bg-gray-100 focus:outline-none active:scale-75 transition-all duration-75"@@ -92,29 +86,33 @@ export default function Globe() {><X className="w-4 h-4" /></button>- <Drag className="h-12 w-12 mx-auto mb-4 text-gray-700 animate-wiggle" />+ <Drag className="h-12 w-12 mx-auto mb-2 sm:mb-4 text-gray-700 animate-wiggle" /><p className="text-center text-gray-700 text-sm sm:text-base">This map shows the locations of the last 30 clicks on{" "}<aclassName="text-blue-800 font-semibold"- href="https://dub.sh/github"+ href={+ hostname ? `https://${hostname}` : "https://dub.sh/github"+ }target="_blank"rel="noreferrer">- dub.sh/github+ {hostname || "dub.sh/github"}</a>{" "}in real time.</p>- <Link- href={{ pathname: "/", query: { key: "github" } }}- as="/stats/github"- shallow- scroll={false}- >- <a className="rounded-full px-4 py-1.5 bg-black text-white hover:bg-white hover:text-black text-sm border border-black mx-auto mt-3 block max-w-fit">- View all stats- </a>- </Link>+ {!hostname && (+ <Link+ href={{ pathname: "/", query: { key: "github" } }}+ as="/stats/github"+ shallow+ scroll={false}+ >+ <a className="rounded-full px-4 py-1.5 bg-black text-white hover:bg-white hover:text-black text-sm border border-black mx-auto mt-2 sm:mt-4 block max-w-fit">+ View all stats+ </a>+ </Link>+ )}</motion.div>)}</AnimatePresence>diff --git a/components/home/hero.tsx b/components/home/hero.tsxindex ed848480bd..79aeb1464e 100644--- a/components/home/hero.tsx+++ b/components/home/hero.tsx@@ -36,7 +36,7 @@ const Hero = () => {</Link><aclassName="flex justify-center items-center space-x-2 py-2 px-5 bg-white rounded-full border border-gray-300 hover:border-gray-800 transition-all"- href="https://dub.sh/github"+ href="https://github.com/steven-tey/dub"target="_blank"rel="noreferrer">diff --git a/components/home/pricing.tsx b/components/home/pricing.tsxindex 1d5e5948a9..bd533da31c 100644--- a/components/home/pricing.tsx+++ b/components/home/pricing.tsx@@ -33,11 +33,7 @@ const pricingItems = [plan: "Enterprise",tagline: "For businesses with custom needs",price: "Custom",- features: [- "Free custom domains",- "Unlimited links",- "Unlimited link clicks",- ],+ features: ["Unlimited links", "Unlimited link clicks", "SSO/SAML"],cta: "Contact us",ctaLink: "mailto:[email protected]?subject=Interested%20in%20Dub%20Enterprise",},diff --git a/components/layout/app/index.tsx b/components/layout/app/index.tsxindex 9339847574..849e08449f 100644--- a/components/layout/app/index.tsx+++ b/components/layout/app/index.tsx@@ -6,6 +6,9 @@ import { Logo, Divider } from "@/components/shared/icons";import ListBox from "./list-box";import UserDropdown from "./user-dropdown";import { useRouter } from "next/router";+import Script from "next/script";++const CRISP_SCRIPT = `window.$crisp=[];window.CRISP_WEBSITE_ID="2c09b1ee-14c2-46d1-bf72-1dbb998a19e0";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();`;const NavTabs = dynamic(() => import("./nav-tabs"), {ssr: false,@@ -22,6 +25,13 @@ export default function AppLayout({ children }: { children: ReactNode }) {return (<div><Meta />+ <Script+ id="script-crisp"+ dangerouslySetInnerHTML={{+ __html: CRISP_SCRIPT,+ }}+ strategy="lazyOnload"+ /><div className="min-h-screen w-full bg-gray-50"><div className="sticky top-0 left-0 right-0 border-b bg-white border-gray-200 z-20"><div className="max-w-screen-xl mx-auto px-5 sm:px-20">diff --git a/components/layout/home/index.tsx b/components/layout/home/index.tsxindex 6a5b833897..4eb203f448 100644--- a/components/layout/home/index.tsx+++ b/components/layout/home/index.tsx@@ -8,7 +8,7 @@ import Footer from "@/components/home/footer";export default function HomeLayout({ children }: { children: ReactNode }) {const { data: session } = useSession();return (- <div>+ <div className="min-h-screen flex flex-col justify-between"><Meta /><div className="bg-white z-20"><div className="max-w-screen-xl mx-auto px-5 sm:px-20">diff --git a/lib/middleware/root.ts b/lib/middleware/root.tsindex de324ad30f..e0030d3c18 100644--- a/lib/middleware/root.ts+++ b/lib/middleware/root.ts@@ -21,7 +21,7 @@ export default function RootMiddleware(req: NextRequest, ev: NextFetchEvent) {return NextResponse.next();} else {const url = req.nextUrl;- url.pathname = "/placeholder"; // rewrite to a /placeholder page unless the user defines a site to redirect to+ url.pathname = `/placeholder/${hostname}`; // rewrite to a /placeholder page unless the user defines a site to redirect toreturn NextResponse.rewrite(url);}}diff --git a/pages/_document.tsx b/pages/_document.tsxindex 25fa6b51b9..4c94398e1c 100644--- a/pages/_document.tsx+++ b/pages/_document.tsx@@ -1,20 +1,10 @@import { Html, Head, Main, NextScript } from "next/document";-import Script from "next/script";--const CRISP_SCRIPT = `window.$crisp=[];window.CRISP_WEBSITE_ID="2c09b1ee-14c2-46d1-bf72-1dbb998a19e0";(function(){d=document;s=d.createElement("script");s.src="https://client.crisp.chat/l.js";s.async=1;d.getElementsByTagName("head")[0].appendChild(s);})();`;export default function Document() {return (<Html className="min-h-screen bg-white"><Head /><body>- <Script- id="script-crisp"- dangerouslySetInnerHTML={{- __html: CRISP_SCRIPT,- }}- strategy="afterInteractive"- /><Main /><NextScript /></body>diff --git a/pages/api/edge/coordinates.ts b/pages/api/edge/coordinates.tsindex 53b78a91eb..28ad8f136e 100644--- a/pages/api/edge/coordinates.ts+++ b/pages/api/edge/coordinates.ts@@ -9,8 +9,9 @@ export const config = {export default async function handler(req: NextRequest) {if (req.method === "GET") {const numPoints = 30;+ const hostname = req.nextUrl.searchParams.get("hostname");const rawData = await redis.zrange<RawStatsProps[]>(- "dub.sh:clicks:github",+ hostname ? `${hostname}:root:clicks` : "dub.sh:clicks:github",0,numPoints,{ rev: true }diff --git a/pages/app/index.tsx b/pages/app/index.tsxindex 4da97f2beb..002a950e8f 100644--- a/pages/app/index.tsx+++ b/pages/app/index.tsx@@ -21,7 +21,7 @@ export default function App() {<h1 className="text-2xl text-gray-600">My Projects</h1><buttononClick={() => setShowAddProjectModal(true)}- className="text-gray-500 hover:border-black active:scale-95 font-medium text-sm px-5 py-2 border rounded-md border-gray-200 transition-all duration-75"+ className="text-white hover:text-black bg-black hover:bg-white active:scale-95 font-medium text-sm px-5 py-2 border rounded-md border-black transition-all duration-75">Add</button>diff --git a/pages/placeholder.tsx b/pages/placeholder.tsxdeleted file mode 100644index 21240d69df..0000000000--- a/pages/placeholder.tsx+++ /dev/null@@ -1,18 +0,0 @@-import HomeLayout from "@/components/layout/home";-import MaxWidthWrapper from "@/components/shared/max-width-wrapper";-import Globe from "@/components/home/globe";--export default function Placeholder() {- return (- <HomeLayout>- <MaxWidthWrapper>- <div className="mt-36 text-center">- <h1 className="font-display font-semibold text-3xl text-gray-700">- This is a custom domain from Dub.sh- </h1>- </div>- </MaxWidthWrapper>- <Globe />- </HomeLayout>- );-}diff --git a/pages/placeholder/[[...hostname]].tsx b/pages/placeholder/[[...hostname]].tsxnew file mode 100644index 0000000000..36dfb78758--- /dev/null+++ b/pages/placeholder/[[...hostname]].tsx@@ -0,0 +1,43 @@+import HomeLayout from "@/components/layout/home";+import MaxWidthWrapper from "@/components/shared/max-width-wrapper";+import Globe from "@/components/home/globe";+import { ParsedUrlQuery } from "querystring";+import { GetStaticProps } from "next";++export default function Placeholder({ hostname }: { hostname: string }) {+ return (+ <HomeLayout>+ {/* <MaxWidthWrapper>+ <div className="mt-36 text-center">+ <h1 className="font-display font-semibold text-3xl text-gray-700">+ This is a custom domain from Dub.sh+ </h1>+ </div>+ </MaxWidthWrapper> */}+ <Globe hostname={hostname} />+ </HomeLayout>+ );+}+interface Params extends ParsedUrlQuery {+ slug: string[];+}++export const getStaticPaths = async () => {+ const paths = [+ { params: { hostname: [] } },+ { params: { hostname: ["stey.me"] } },+ ];+ return {+ paths,+ fallback: "blocking",+ };+};++export const getStaticProps: GetStaticProps = async (context) => {+ const { hostname } = context.params as Params;+ return {+ props: {+ hostname: hostname ? hostname[0] : "dub.sh",+ },+ };+};diff --git a/public/static/twitter-banner.png b/public/static/twitter-banner.pngnew file mode 100644index 0000000000..a3c0e026caBinary files /dev/null and b/public/static/twitter-banner.png differ