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.

added all bento content, added qr picker to qr codes page

Steven Teyd619b876ebcf
diff --git a/app/dub.co/features/[slug]/page.tsx b/app/dub.co/features/[slug]/page.tsx
index 93aaf6ddca..a2a0cbcddd 100644
--- a/app/dub.co/features/[slug]/page.tsx
+++ b/app/dub.co/features/[slug]/page.tsx
@@ -1,6 +1,6 @@
import { APP_DOMAIN } from "#/lib/constants";
import { FEATURES_LIST } from "#/lib/constants/content";
-import { constructMetadata } from "#/lib/utils";
+import { cn, constructMetadata } from "#/lib/utils";
import BlurImage from "#/ui/blur-image";
import CTA from "#/ui/home/cta";
import Logos from "#/ui/home/logos";
@@ -8,6 +8,8 @@ import { PlayCircle } from "lucide-react";
import { notFound } from "next/navigation";
import DemoVideo from "./video";
import MaxWidthWrapper from "@/components/shared/max-width-wrapper";
+import Link from "next/link";
+import { QRCodePicker } from "#/ui/modals/link-qr-modal";
export function generateMetadata({
params,
@@ -76,40 +78,72 @@ export default function FeaturePage({
<MaxWidthWrapper className="py-20 text-center">
<div className="mx-auto max-w-xl">
<h2 className="font-display text-3xl font-extrabold leading-[1.15] text-black [text-wrap:balance] sm:text-5xl sm:leading-[1.15]">
- Detailed insights for every click
+ {data.bentoTitle}
</h2>
<p className="mt-5 text-gray-600 sm:text-lg">
- Dub provides detailed analytics for every click on your links. See
- where your audience is coming from and what devices they are using.
+ {data.bentoDescription}
</p>
</div>
- <div className="mt-10 grid gap-4 sm:grid-cols-2">
- <BentoCard />
- <BentoCard />
- </div>
+ {data.slug === "qr-codes" ? (
+ <div className="mx-auto mt-10 max-w-md rounded-2xl border border-gray-200 bg-white shadow backdrop-blur">
+ <QRCodePicker
+ props={{
+ key: "github",
+ url: "https://github.com/steven-tey/dub",
+ }}
+ />
+ </div>
+ ) : (
+ <>
+ <div className="mt-10 grid gap-4 md:grid-cols-2">
+ {data.bentoFeatures?.slice(0, 2).map((feature, idx) => (
+ <BentoCard key={idx} {...feature} />
+ ))}
+ </div>
+ <div className="mt-4 grid gap-4 md:grid-cols-3">
+ {data.bentoFeatures?.slice(2, 5).map((feature, idx) => (
+ <BentoCard key={idx} {...feature} />
+ ))}
+ </div>
+ </>
+ )}
</MaxWidthWrapper>
<CTA />
</>
);
}
-const BentoCard = () => {
- return (
- <div className="relative h-[400px] overflow-hidden rounded-3xl border border-gray-200 bg-white/50 p-8 shadow backdrop-blur">
+const BentoCard = ({
+ title,
+ description,
+ href,
+}: {
+ title: string;
+ description: string;
+ href?: string;
+}) => {
+ const contents = (
+ <div
+ className={cn(
+ "relative h-[400px] overflow-hidden rounded-3xl border border-gray-200 bg-white/50 p-8 shadow backdrop-blur",
+ {
+ "transition-all hover:shadow-lg": href,
+ },
+ )}
+ >
{/* <img
src="/_static/features/analytics.svg"
alt="Analytics"
className="h-full w-full"
/> */}
<div className="absolute bottom-0 left-0 right-0 p-8">
- <h3 className="text-xl font-semibold text-gray-700">
- Powerful analytics for the modern marketer
- </h3>
- <p className="mt-2 text-gray-500">
- Dub provides powerful analytics for your links, including geolocation,
- device, browser, and referrer information.
- </p>
+ <h3 className="text-xl font-semibold text-gray-700">{title}</h3>
+ <p className="mt-2 text-gray-500 [text-wrap:balance]">{description}</p>
</div>
</div>
);
+ if (href) {
+ return <Link href={href}>{contents}</Link>;
+ }
+ return contents;
};
diff --git a/app/ui/modals/link-qr-modal.tsx b/app/ui/modals/link-qr-modal.tsx
index ca0317842a..3c70b31e3c 100644
--- a/app/ui/modals/link-qr-modal.tsx
+++ b/app/ui/modals/link-qr-modal.tsx
@@ -24,6 +24,7 @@ import IconMenu from "@/components/shared/icon-menu";
import Popover from "#/ui/popover";
import { toast } from "sonner";
import { GOOGLE_FAVICON_URL } from "#/lib/constants";
+import { useDebouncedCallback } from "use-debounce";
function LinkQRModalHelper({
showLinkQRModal,
@@ -34,6 +35,14 @@ function LinkQRModalHelper({
setShowLinkQRModal: Dispatch<SetStateAction<boolean>>;
props: SimpleLinkProps;
}) {
+ return (
+ <Modal showModal={showLinkQRModal} setShowModal={setShowLinkQRModal}>
+ <QRCodePicker props={props} />
+ </Modal>
+ );
+}
+
+export function QRCodePicker({ props }: { props: SimpleLinkProps }) {
const anchorRef = useRef<HTMLAnchorElement>(null);
const { logo } = useProject();
const { avatarUrl, apexDomain } = useMemo(() => {
@@ -55,7 +64,7 @@ function LinkQRModalHelper({
if (logo) return logo;
return typeof window !== "undefined" && window.location.origin
? new URL("/_static/logo.svg", window.location.origin).href
- : "";
+ : "https://dub.sh/_static/logo.svg";
}, [logo]);
function download(url: string, extension: string) {
@@ -102,9 +111,8 @@ function LinkQRModalHelper({
throw e;
}
};
-
return (
- <Modal showModal={showLinkQRModal} setShowModal={setShowLinkQRModal}>
+ <>
<div className="flex flex-col items-center justify-center space-y-3 border-b border-gray-200 px-4 py-4 pt-8 sm:px-16">
{avatarUrl ? (
<BlurImage
@@ -179,18 +187,16 @@ function LinkQRModalHelper({
ref={anchorRef}
/>
</div>
- </Modal>
+ </>
);
}
function AdvancedSettings({ qrData, setFgColor, showLogo, setShowLogo }) {
const { plan } = useProject();
const [expanded, setExpanded] = useState(false);
-
- const isApp = useMemo(() => {
- if (typeof window === "undefined") return false;
- return window.location.host.startsWith("app.");
- }, []);
+ const debouncedSetFgColor = useDebouncedCallback((color) => {
+ setFgColor(color);
+ }, 100);
return (
<div>
@@ -265,7 +271,7 @@ function AdvancedSettings({ qrData, setFgColor, showLogo, setShowLogo }) {
<div className="flex max-w-xs flex-col items-center space-y-3 p-5 text-center">
<HexColorPicker
color={qrData.fgColor}
- onChange={(color) => setFgColor(color)}
+ onChange={debouncedSetFgColor}
/>
</div>
}
@@ -298,60 +304,58 @@ function AdvancedSettings({ qrData, setFgColor, showLogo, setShowLogo }) {
function QrDropdown({ download, qrData, showLogo, logo }) {
const [openPopover, setOpenPopover] = useState(false);
return (
- <>
- <Popover
- content={
- <div className="grid w-full gap-1 p-2 sm:w-40">
- <button
- onClick={() => {
- download(
- getQRAsSVGDataUri({
- ...qrData,
- ...(showLogo && {
- imageSettings: {
- ...qrData.imageSettings,
- src: logo || "https://dub.co/_static/logo.svg",
- },
- }),
+ <Popover
+ content={
+ <div className="grid w-full gap-1 p-2 sm:w-40">
+ <button
+ onClick={() => {
+ download(
+ getQRAsSVGDataUri({
+ ...qrData,
+ ...(showLogo && {
+ imageSettings: {
+ ...qrData.imageSettings,
+ src: logo || "https://dub.co/_static/logo.svg",
+ },
}),
- "svg",
- );
- }}
- className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
- >
- <IconMenu text="SVG" icon={<Photo className="h-4 w-4" />} />
- </button>
- <button
- onClick={async () => {
- download(await getQRAsCanvas(qrData, "image/png"), "png");
- }}
- className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
- >
- <IconMenu text="PNG" icon={<Photo className="h-4 w-4" />} />
- </button>
- <button
- onClick={async () => {
- download(await getQRAsCanvas(qrData, "image/jpeg"), "jpg");
- }}
- className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
- >
- <IconMenu text="JPEG" icon={<Photo className="h-4 w-4" />} />
- </button>
- </div>
- }
- align="center"
- openPopover={openPopover}
- setOpenPopover={setOpenPopover}
+ }),
+ "svg",
+ );
+ }}
+ className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
+ >
+ <IconMenu text="SVG" icon={<Photo className="h-4 w-4" />} />
+ </button>
+ <button
+ onClick={async () => {
+ download(await getQRAsCanvas(qrData, "image/png"), "png");
+ }}
+ className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
+ >
+ <IconMenu text="PNG" icon={<Photo className="h-4 w-4" />} />
+ </button>
+ <button
+ onClick={async () => {
+ download(await getQRAsCanvas(qrData, "image/jpeg"), "jpg");
+ }}
+ className="w-full rounded-md p-2 text-left text-sm font-medium text-gray-500 transition-all duration-75 hover:bg-gray-100"
+ >
+ <IconMenu text="JPEG" icon={<Photo className="h-4 w-4" />} />
+ </button>
+ </div>
+ }
+ align="center"
+ openPopover={openPopover}
+ setOpenPopover={setOpenPopover}
+ >
+ <button
+ onClick={() => setOpenPopover(!openPopover)}
+ className="flex w-full items-center justify-center gap-2 rounded-md border border-black bg-black px-5 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black"
>
- <button
- onClick={() => setOpenPopover(!openPopover)}
- className="flex w-full items-center justify-center gap-2 rounded-md border border-black bg-black px-5 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black"
- >
- <Download />
- Export
- </button>
- </Popover>
- </>
+ <Download />
+ Export
+ </button>
+ </Popover>
);
}
diff --git a/components/app/modals/link-qr-modal.tsx b/components/app/modals/link-qr-modal.tsx
index 7dd522a429..72d077a087 100644
--- a/components/app/modals/link-qr-modal.tsx
+++ b/components/app/modals/link-qr-modal.tsx
@@ -35,6 +35,7 @@ import {
import { useRouter } from "next/router";
import { ModalContext } from "#/ui/modal-provider";
import { motion } from "framer-motion";
+import { useDebouncedCallback } from "use-debounce";
function LinkQRModalHelper({
showLinkQRModal,
@@ -66,7 +67,7 @@ function LinkQRModalHelper({
if (logo && plan !== "free") return logo;
return typeof window !== "undefined" && window.location.origin
? new URL("/_static/logo.svg", window.location.origin).href
- : "";
+ : "https://dub.sh/_static/logo.svg";
}, [logo, plan]);
function download(url: string, extension: string) {
@@ -207,6 +208,10 @@ function AdvancedSettings({
const { plan, logo } = useProject();
const [expanded, setExpanded] = useState(false);
+ const debouncedSetFgColor = useDebouncedCallback((color) => {
+ setFgColor(color);
+ }, 100);
+
const { setShowAddProjectModal, setShowUpgradePlanModal } =
useContext(ModalContext);
@@ -311,7 +316,7 @@ function AdvancedSettings({
<div className="flex max-w-xs flex-col items-center space-y-3 p-5 text-center">
<HexColorPicker
color={qrData.fgColor}
- onChange={(color) => setFgColor(color)}
+ onChange={debouncedSetFgColor}
/>
</div>
}
diff --git a/lib/constants/content.tsx b/lib/constants/content.tsx
index 314e61e338..6047fbde32 100644
--- a/lib/constants/content.tsx
+++ b/lib/constants/content.tsx
@@ -115,6 +115,36 @@ export const FEATURES_LIST = [
thumbnail: "https://d2vwwcvoksz7ty.cloudfront.net/features/analytics.png",
videoUrl:
"https://www.youtube.com/embed/m062ApqcRow?si=8FRndy4ABWPTioHU&autoplay=1",
+ bentoTitle: "Detailed insights for every click",
+ bentoDescription:
+ "Dub provides detailed analytics for every click on your links. See where your audience is coming from and what devices they are using.",
+ bentoFeatures: [
+ {
+ title: "Time-series data",
+ description:
+ "See how your links are performing over time with a beautiful time-series chart.",
+ },
+ {
+ title: "Geographic data",
+ description:
+ "Understand your audience with geographic data – on both a country and city level.",
+ },
+ {
+ title: "Device data",
+ description:
+ "See what devices your audience is using to click on your links",
+ },
+ {
+ title: "Referrer data",
+ description:
+ "Understand which websites are driving the most traffic to your links.",
+ },
+ {
+ title: "404 monitoring",
+ description:
+ "Monitor your links for 404 errors and notifies you when they occur.",
+ },
+ ],
},
{
title: "Branded Links that Stand Out",
@@ -127,6 +157,40 @@ export const FEATURES_LIST = [
thumbnail: "https://d2vwwcvoksz7ty.cloudfront.net/features/analytics.png",
videoUrl:
"https://www.youtube.com/embed/m062ApqcRow?si=8FRndy4ABWPTioHU&autoplay=1",
+ bentoTitle: "Impress your audience with branded links",
+ bentoDescription:
+ "Create custom short links that match your brand and stand out from the crowd, with free and unlimited custom domains on all plans.",
+ bentoFeatures: [
+ {
+ title: "Unlimited custom domains",
+ description:
+ "Add as many custom domains as you want to your project at no extra cost.",
+ href: "/help/article/how-to-add-custom-domain",
+ },
+ {
+ title: "Free SSL certificates",
+ description:
+ "Dub automatically provisions and renews SSL certificates for your custom domains.",
+ },
+ {
+ title: "Vanity URLs",
+ description:
+ "Create custom paths for your links to make them even more memorable.",
+ href: "/help/article/how-to-create-link",
+ },
+ {
+ title: "Link cloaking",
+ description:
+ "Hide your destination URL with link cloaking to make your links look cleaner.",
+ href: "/help/article/how-to-create-link#link-cloaking",
+ },
+ {
+ title: "Custom QR codes",
+ description:
+ "With Dub Pro, you can create branded QR codes for your links.",
+ href: "/features/qr-codes",
+ },
+ ],
},
{
title: "Free QR Code Generator",
@@ -139,6 +203,9 @@ export const FEATURES_LIST = [
thumbnail: "https://d2vwwcvoksz7ty.cloudfront.net/features/analytics.png",
videoUrl:
"https://www.youtube.com/embed/m062ApqcRow?si=8FRndy4ABWPTioHU&autoplay=1",
+ bentoTitle: "Gorgeous QR codes for your links",
+ bentoDescription:
+ "Create beautiful flyers and posters with QR codes for your links.",
},
{
title: "Personalize Your Short links",
@@ -151,6 +218,41 @@ export const FEATURES_LIST = [
thumbnail: "https://d2vwwcvoksz7ty.cloudfront.net/features/analytics.png",
videoUrl:
"https://www.youtube.com/embed/m062ApqcRow?si=8FRndy4ABWPTioHU&autoplay=1",
+ bentoTitle: "Optimize your links for every audience",
+ bentoDescription:
+ "Get the most out of every click by delivering the right experience to the right audience.",
+ bentoFeatures: [
+ {
+ title: "Device targeting",
+ description:
+ "Redirect your audience to different destinations based on their device type (e.g. iOS/Android).",
+ href: "/help/article/how-to-create-link#device-targeting-ios--android",
+ },
+ {
+ title: "Geo targeting",
+ description:
+ "Redirect your audience to different destinations based on their country of origin.",
+ href: "/help/article/how-to-create-link#geo-targeting",
+ },
+ {
+ title: "Expiration dates",
+ description:
+ "Automatically disable your links after a certain date & time.",
+ href: "/help/article/how-to-create-link#expiration-date",
+ },
+ {
+ title: "Password protection",
+ description:
+ "Protect your links with passwords to prevent unauthorized access.",
+ href: "/help/article/how-to-create-link#password-protection",
+ },
+ {
+ title: "Link cloaking",
+ description:
+ "Hide your destination URL with link cloaking to make your links look cleaner.",
+ href: "/help/article/how-to-create-link#link-cloaking",
+ },
+ ],
},
// { title: "Programmatic Link Creation", shortTitle: "API", slug: "api" },
{
@@ -164,5 +266,38 @@ export const FEATURES_LIST = [
thumbnail: "https://d2vwwcvoksz7ty.cloudfront.net/features/analytics.png",
videoUrl:
"https://www.youtube.com/embed/m062ApqcRow?si=8FRndy4ABWPTioHU&autoplay=1",
+ bentoTitle: "Seamless collaboration for marketing teams",
+ bentoDescription:
+ "View and manage your team's links in one place, with fine-grained permissions and SAML SSO for enterprises.",
+ bentoFeatures: [
+ {
+ title: "Unlimited teammates",
+ description:
+ "All paid plans come with unlimited teammates, so you can work with your team without worrying about extra costs.",
+ href: "/help/article/how-to-invite-teammates",
+ },
+ {
+ title: "SAML SSO",
+ description:
+ "Dub offers SAML SSO for enterprises to provide better security and control over their projects.",
+ href: "/help/category/saml-sso",
+ },
+ {
+ title: "Tags & comments",
+ description:
+ "Organize your links with tags and comments to provide context for your team.",
+ href: "/help/article/how-to-use-tags",
+ },
+ {
+ title: "Fine-grained permissions",
+ description:
+ "Enterprises on Dub can set role-based access controls (RBAC) to control who can create, edit, and delete links.",
+ },
+ {
+ title: "Team analytics",
+ description:
+ "See how your team is performing with team analytics, including link clicks and top referrers.",
+ },
+ ],
},
];
diff --git a/lib/swr-app/use-project.ts b/lib/swr-app/use-project.ts
index f6fac68100..8315b650aa 100644
--- a/lib/swr-app/use-project.ts
+++ b/lib/swr-app/use-project.ts
@@ -8,7 +8,7 @@ export default function useProject() {
const { slug } = useParams() as { slug?: string };
const { data: project, error } = useSWR<ProjectProps>(
- slug && `/api/projects/${slug}`,
+ slug && slug !== "qr-codes" && `/api/projects/${slug}`,
fetcher,
{
dedupingInterval: 30000,
diff --git a/next.config.js b/next.config.js
index 7eb79f65a4..c1b99e9c7a 100644
--- a/next.config.js
+++ b/next.config.js
@@ -18,6 +18,24 @@ const nextConfig = {
serverActions: true,
useDeploymentIdServerActions: true,
},
+ webpack: (config, { webpack, isServer }) => {
+ if (isServer) {
+ // Module not found
+ config.plugins.push(
+ new webpack.IgnorePlugin({
+ resourceRegExp:
+ /(^@google-cloud\/spanner|^@mongodb-js\/zstd|^aws-crt|^aws4$|^pg-native$|^mongodb-client-encryption$|^@sap\/hana-client$|^snappy$|^react-native-sqlite-storage$|^bson-ext$|^cardinal$|^kerberos$|^hdb-pool$|^sql.js$|^sqlite3$|^better-sqlite3$|^ioredis$|^typeorm-aurora-data-api-driver$|^pg-query-stream$|^oracledb$|^mysql$|^snappy\/package\.json$|^cloudflare:sockets$)/,
+ }),
+ );
+ }
+
+ config.module = {
+ ...config.module,
+ exprContextCritical: false,
+ };
+
+ return config;
+ },
images: {
domains: [
"www.google.com",