The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added tailwind-merge, added tags section
Steven Tey0030b97009b7
diff --git a/app/layout.tsx b/app/layout.tsxindex 93ae543fba..41e7323240 100644--- a/app/layout.tsx+++ b/app/layout.tsx@@ -1,8 +1,7 @@import "@/styles/globals.css";import { satoshi, inter } from "@/styles/fonts";import { Analytics } from "@vercel/analytics/react";-import clsx from "clsx";-import { constructMetadata } from "#/lib/utils";+import { cn, constructMetadata } from "#/lib/utils";export const metadata = constructMetadata({});@@ -13,7 +12,7 @@ export default function RootLayout({}) {return (<html lang="en">- <body className={clsx(satoshi.variable, inter.variable)}>+ <body className={cn(satoshi.variable, inter.variable)}>{children}<Analytics /></body>diff --git a/app/ui/badge.tsx b/app/ui/badge.tsxindex aeb3ba094f..f087dacf75 100644--- a/app/ui/badge.tsx+++ b/app/ui/badge.tsx@@ -1,4 +1,4 @@-import clsx from "clsx";+import { cn } from "#/lib/utils";export default function Badge({text,@@ -11,7 +11,7 @@ export default function Badge({}) {return (<span- className={clsx(+ className={cn("rounded-full border px-2 py-px text-xs font-medium capitalize",{"border-violet-600 bg-violet-600 text-white": variant === "purple",diff --git a/app/ui/button.tsx b/app/ui/button.tsxindex ec4175923a..edd1384791 100644--- a/app/ui/button.tsx+++ b/app/ui/button.tsx@@ -2,7 +2,7 @@import { LoadingDots } from "#/ui/icons";import Tooltip from "#/ui/tooltip";-import clsx from "clsx";+import { cn } from "#/lib/utils";import { ReactNode } from "react";export default function Button({@@ -35,7 +35,7 @@ export default function Button({<button// if onClick is passed, it's a "button" type, otherwise it's being used in a form, hence "submit"type={onClick ? "button" : "submit"}- className={clsx(+ className={cn("flex h-10 w-full items-center justify-center space-x-2 rounded-md border text-sm transition-all focus:outline-none",disabled || loading? "cursor-not-allowed border-gray-200 bg-gray-100 text-gray-400"diff --git a/app/ui/home/nav.tsx b/app/ui/home/nav.tsxindex 5d6be8a722..d3cbbcc918 100644--- a/app/ui/home/nav.tsx+++ b/app/ui/home/nav.tsx@@ -4,7 +4,7 @@ import Link from "next/link";import Image from "next/image";import { useParams, useSelectedLayoutSegment } from "next/navigation";import useScroll from "#/lib/hooks/use-scroll";-import clsx from "clsx";+import { cn } from "#/lib/utils";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";const navItems = ["pricing", "changelog"];@@ -19,7 +19,7 @@ export default function Nav() {return (<div- className={clsx(`sticky inset-x-0 top-0 z-30 w-full transition-all`, {+ className={cn(`sticky inset-x-0 top-0 z-30 w-full transition-all`, {"border-b border-gray-200 bg-white/75 backdrop-blur-lg": scrolled,"border-b border-gray-200 bg-white":segment && !transparentHeaderSegments.has(segment),diff --git a/app/ui/home/navigation-menu.tsx b/app/ui/home/navigation-menu.tsxindex 58fc069b8c..2cbf5d9ac0 100644--- a/app/ui/home/navigation-menu.tsx+++ b/app/ui/home/navigation-menu.tsx@@ -1,7 +1,7 @@"use client";import * as NavigationMenuPrimitive from "@radix-ui/react-navigation-menu";-import clsx from "clsx";+import { cn } from "#/lib/utils";import Link from "next/link";import React from "react";@@ -30,7 +30,7 @@ export default function NavigationMenu() {<NavigationMenuPrimitive.List className="flex flex-row space-x-2 p-2">{/* <NavigationMenuPrimitive.Item><NavigationMenuPrimitive.Trigger- className={clsx(+ className={cn("group flex items-center space-x-2 rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900","text-sm font-medium","text-gray-700 dark:text-gray-100",@@ -42,7 +42,7 @@ export default function NavigationMenu() {</NavigationMenuPrimitive.Trigger><NavigationMenuPrimitive.Content- className={clsx(+ className={cn("absolute top-0 left-0 w-auto rounded-lg","radix-motion-from-start:animate-enter-from-left","radix-motion-from-end:animate-enter-from-right",@@ -67,7 +67,7 @@ export default function NavigationMenu() {<NavigationMenuPrimitive.Item><NavigationMenuPrimitive.Trigger- className={clsx(+ className={cn("group flex items-center space-x-2 rounded-md px-3 py-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-900","text-sm font-medium text-gray-700 dark:text-gray-100","focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75",@@ -78,7 +78,7 @@ export default function NavigationMenu() {</NavigationMenuPrimitive.Trigger><NavigationMenuPrimitive.Content- className={clsx(+ className={cn("absolute top-0 left-0 w-auto rounded-lg","radix-motion-from-start:animate-enter-from-left","radix-motion-from-end:animate-enter-from-right",@@ -91,7 +91,7 @@ export default function NavigationMenu() {{comparisons.map(({ title, slug }) => (<Linkkey={slug}- className={clsx(+ className={cn("w-full rounded-md px-4 py-3 hover:bg-gray-100 dark:hover:bg-gray-900","focus:outline-none focus-visible:ring focus-visible:ring-purple-500 focus-visible:ring-opacity-75",)}@@ -139,7 +139,7 @@ export default function NavigationMenu() {</NavigationMenuPrimitive.Item><NavigationMenuPrimitive.Indicator- className={clsx(+ className={cn("z-10","top-[100%] flex h-2 items-end justify-center overflow-hidden","radix-state-visible:animate-fade-in",@@ -152,7 +152,7 @@ export default function NavigationMenu() {</NavigationMenuPrimitive.List><div- className={clsx(+ className={cn("absolute flex justify-center","left-[-30%] top-[100%] w-[140%]",)}@@ -161,7 +161,7 @@ export default function NavigationMenu() {}}><NavigationMenuPrimitive.Viewport- className={clsx(+ className={cn("relative mt-2 overflow-hidden rounded-md bg-white shadow-lg dark:bg-gray-800","w-radix-navigation-menu-viewport","h-radix-navigation-menu-viewport",diff --git a/app/ui/icons/loading-circle.tsx b/app/ui/icons/loading-circle.tsxindex 92a1f6170e..620e5df3d4 100644--- a/app/ui/icons/loading-circle.tsx+++ b/app/ui/icons/loading-circle.tsx@@ -1,10 +1,13 @@-export default function LoadingCircle({ dimensions }: { dimensions?: string }) {+import { cn } from "#/lib/utils";++export default function LoadingCircle({ className }: { className?: string }) {return (<svgaria-hidden="true"- className={`${- dimensions || "h-4 w-4"- } animate-spin fill-gray-600 text-gray-200`}+ className={cn(+ "h-4 w-4 animate-spin fill-gray-600 text-gray-200",+ className,+ )}viewBox="0 0 100 101"fill="none"xmlns="http://www.w3.org/2000/svg"diff --git a/app/ui/switch.tsx b/app/ui/switch.tsxindex 84fa1fb037..e68d6d5fa6 100644--- a/app/ui/switch.tsx+++ b/app/ui/switch.tsx@@ -2,7 +2,7 @@import { Dispatch, SetStateAction } from "react";import * as SwitchPrimitive from "@radix-ui/react-switch";-import clsx from "clsx";+import { cn } from "#/lib/utils";const Switch = ({fn,@@ -25,13 +25,13 @@ const Switch = ({name="switch"onCheckedChange={(checked) => fn(checked)}disabled={disabled}- className={clsx(+ className={cn(disabled ? "cursor-not-allowed" : "cursor-pointer",`relative inline-flex ${trackDimensions} flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75 radix-state-checked:bg-blue-500 radix-state-unchecked:bg-gray-200`,)}><SwitchPrimitive.Thumb- className={clsx(+ className={cn(`radix-state-checked:${thumbTranslate}`,"radix-state-unchecked:translate-x-0",`pointer-events-none ${thumbDimensions} transform ${thumbTranslate} rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`,diff --git a/app/ui/tweet.tsx b/app/ui/tweet.tsxindex 37b17b8dee..4ed56fe846 100644--- a/app/ui/tweet.tsx+++ b/app/ui/tweet.tsx@@ -1,11 +1,10 @@"use client";import BlurImage from "#/ui/blur-image";-import { nFormatter, truncate } from "#/lib/utils";+import { cn, nFormatter, truncate } from "#/lib/utils";import { Heart, Message, Twitter } from "@/components/shared/icons";import Tilt from "react-parallax-tilt";import { enrichTweet } from "react-tweet";-import clsx from "clsx";import { Tweet } from "react-tweet/api";export default function Tweet({@@ -67,7 +66,7 @@ export default function Tweet({height={48}width={48}src={user.profile_image_url_https}- className={clsx(+ className={cn("h-10 w-10 overflow-hidden rounded-full border border-gray-200 transition-all ease-in-out hover:scale-105",{// @ts-expect-error@@ -91,7 +90,7 @@ export default function Tweet({user.verified_type ? (<svgaria-label="Verified Account"- className={clsx("ml-1 inline h-4 w-4", {+ className={cn("ml-1 inline h-4 w-4", {"text-blue-500": user.is_blue_verified,"text-yellow-500": user.verified_type === "Business",})}@@ -182,7 +181,7 @@ export default function Tweet({)}{photos && (<div- className={clsx({+ className={cn({"inline-grid grid-cols-2 gap-x-2 gap-y-2": photos.length > 1,})}>diff --git a/components/app/domains/domain-card.tsx b/components/app/domains/domain-card.tsxindex c139d579d5..5d66859851 100644--- a/components/app/domains/domain-card.tsx+++ b/components/app/domains/domain-card.tsx@@ -111,7 +111,7 @@ export default function DomainCard({ props }: { props: DomainProps }) {<XCircleFill className="h-6 w-6 text-red-500" />)) : (- <LoadingCircle dimensions="w-5 h-5 mr-1" />+ <LoadingCircle className="mr-1 h-5 w-5" />)}<p className="text-sm text-gray-500">{data ? data.status : "Checking Domain Status"}diff --git a/components/app/links/tag-badge.tsx b/components/app/links/tag-badge.tsxindex e637c052b0..eb080ad1f6 100644--- a/components/app/links/tag-badge.tsx+++ b/components/app/links/tag-badge.tsx@@ -1,6 +1,5 @@import { TagColorProps } from "#/lib/types";-import { truncate } from "#/lib/utils";-import clsx from "clsx";+import { cn, truncate } from "#/lib/utils";import { Tag } from "lucide-react";export default function TagBadge({@@ -14,7 +13,7 @@ export default function TagBadge({}) {return (<span- className={clsx(+ className={cn("my-auto whitespace-nowrap rounded-md px-2 py-0.5 text-sm",withIcon && "flex items-center space-x-1.5",color === "red" && "bg-red-100 text-red-600",diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsxindex 3f18039573..1cff211636 100644--- a/components/app/modals/add-edit-link-modal/index.tsx+++ b/components/app/modals/add-edit-link-modal/index.tsx@@ -21,6 +21,7 @@ import {getApexDomain,getQueryString,getUrlWithoutUTMParams,+ isValidUrl,linkConstructor,truncate,} from "#/lib/utils";@@ -528,7 +529,7 @@ function AddEditLinkModal({</div><div className="grid gap-5 px-4 md:px-16">- <TagsSection {...{ props, data, setData }} />+ {slug && <TagsSection {...{ props, data, setData }} />}<OGSection{...{ props, data, setData }}generatingMetatags={generatingMetatags}@@ -601,9 +602,21 @@ function AddEditLinkButton({}}, []);+ // listen to paste event, and if it's a URL, open the modal and input the URL+ const handlePaste = (e: ClipboardEvent) => {+ const pastedContent = e.clipboardData?.getData("text");+ if (pastedContent && isValidUrl(pastedContent)) {+ setShowAddEditLinkModal(true);+ }+ };+useEffect(() => {document.addEventListener("keydown", onKeyDown);- return () => document.removeEventListener("keydown", onKeyDown);+ document.addEventListener("paste", handlePaste);+ return () => {+ document.removeEventListener("keydown", onKeyDown),+ document.removeEventListener("paste", handlePaste);+ };}, [onKeyDown]);return slug && exceededUsage ? ( // only show exceeded usage tooltip if user is on a project pagediff --git a/components/app/modals/add-edit-link-modal/tags-section.tsx b/components/app/modals/add-edit-link-modal/tags-section.tsxindex 1fce0fc33e..2e202fa74a 100644--- a/components/app/modals/add-edit-link-modal/tags-section.tsx+++ b/components/app/modals/add-edit-link-modal/tags-section.tsx@@ -1,18 +1,15 @@import {Dispatch,- KeyboardEvent,SetStateAction,- useCallback,+ useEffect,+ useMemo,useRef,useState,} from "react";-import { Check, Trash, X } from "lucide-react";+import { Check, Search, Trash, X } from "lucide-react";import { Command } from "cmdk";import TagBadge, { COLORS_LIST } from "../../links/tag-badge";import { LinkProps, TagProps } from "#/lib/types";-import Switch from "#/ui/switch";-import { motion } from "framer-motion";-import { FADE_IN_ANIMATION_SETTINGS } from "#/lib/constants";import useTags from "#/lib/swr/use-tags";import { useRouter } from "next/router";import { toast } from "sonner";@@ -20,129 +17,140 @@ import { mutate } from "swr";import { LoadingCircle } from "#/ui/icons";import Popover from "@/components/shared/popover";import IconMenu from "@/components/shared/icon-menu";-import { ThreeDots } from "@/components/shared/icons";+import { ChevronDown, ThreeDots } from "@/components/shared/icons";export default function TagsSection({- props,data,setData,}: {- props?: LinkProps;data: LinkProps;setData: Dispatch<SetStateAction<LinkProps>>;}) {const { tagId } = data;const { tags } = useTags();- const inputRef = useRef<HTMLInputElement>(null);- const [open, setOpen] = useState(false);- const [selected, setSelected] = useState<TagProps[]>(- tags?.filter((tag) => tag.id === tagId) || [],- );+ const selectedTag = useMemo(() => {+ if (tagId) {+ return tags?.find((tag) => tag.id === tagId);+ }+ }, [tagId, tags]);+const [inputValue, setInputValue] = useState("");- const handleUnselect = useCallback((tag: TagProps) => {- setSelected((prev) => prev.filter((s) => s.id !== tag.id));- }, []);+ const [creatingTag, setCreatingTag] = useState(false);- const handleKeyDown = useCallback((e: KeyboardEvent<HTMLDivElement>) => {- const input = inputRef.current;- if (input) {- if (e.key === "Delete" || e.key === "Backspace") {- if (input.value === "") {- setSelected((prev) => {- const newSelected = [...prev];- newSelected.pop();- return newSelected;- });- }- }- // This is not a default behaviour of the <input /> field- if (e.key === "Escape") {- input.blur();+ const commandRef = useRef<HTMLDivElement | null>(null);+ const [openCommandList, setOpenCommandList] = useState(false);++ useEffect(() => {+ const handleClickOutside = (e) => {+ if (commandRef.current && !commandRef.current.contains(e.target)) {+ setOpenCommandList(false);}+ };+ if (openCommandList) {+ document.addEventListener("click", handleClickOutside);+ return () => document.removeEventListener("click", handleClickOutside);}- }, []);+ }, [commandRef, openCommandList]);return (<div className="border-b border-gray-200 pb-5">- <h2 className="text-sm font-medium text-gray-900">Tags</h2>- <Command- className="mt-3 overflow-visible bg-white"- loop- shouldFilter={- inputValue.length > 0 && !tags?.find((t) => t.name === inputValue)- }- >- <div className="group rounded-md border border-gray-300 px-1 focus-within:border-gray-500 focus-within:ring-1 focus-within:ring-gray-500">- <div className="flex flex-wrap gap-1">- {selected.map((tag) => {- return (- // <Badge key={framework.value} variant="secondary">- // {framework.label}- // <button- // className="ml-1 ring-offset-background rounded-full outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2"- // onKeyDown={(e) => {- // if (e.key === "Enter") {- // handleUnselect(framework);- // }- // }}- // onMouseDown={(e) => {- // e.preventDefault();- // e.stopPropagation();- // }}- // onClick={() => handleUnselect(framework)}- // >- // <X className="h-3 w-3 text-muted-foreground hover:text-foreground" />- // </button>- // </Badge>- <TagBadge key={tag.id} {...tag} />- );- })}- <Command.Input- ref={inputRef}- value={inputValue}- onValueChange={setInputValue}- onKeyDown={handleKeyDown}- onBlur={() => setOpen(false)}- onFocus={() => setOpen(true)}- placeholder="Choose tag"- className="flex-1 rounded-r-md border-none text-sm text-gray-900 placeholder-gray-300 focus:outline-none focus:ring-0"- />+ <Command ref={commandRef} className="relative" loop>+ <div className="group mt-1 rounded-md border border-gray-300 bg-white px-1 focus-within:border-gray-500 focus-within:ring-1 focus-within:ring-gray-500">+ <div className="absolute inset-y-0 left-0 flex items-center justify-center pl-3 text-gray-400">+ {creatingTag ? <LoadingCircle /> : <Search className="h-4 w-4" />}+ </div>+ <div className="flex h-9 px-8">+ {selectedTag ? (+ <TagBadge key={selectedTag.id} {...selectedTag} />+ ) : (+ <Command.Input+ placeholder="Choose a tag"+ value={inputValue}+ onValueChange={setInputValue}+ // only show the dropdown if there are tags and the tagValue is not empty+ onFocus={() =>+ tags && tags.length > 0 && setOpenCommandList(true)+ }+ onKeyDown={(e) => {+ if (e.key === "Escape") {+ e.stopPropagation();+ setOpenCommandList(false);+ } else if (e.key === "Enter") {+ if (openCommandList) {+ // if dropdown is openCommandList, close it+ setOpenCommandList(false);+ } else {+ // if dropdown is already closed, submit form+ }+ // if it's a letter or a number and there's no meta key pressed, openCommandList dropdown+ } else if (e.key.match(/^[a-z0-9]$/i) && !e.metaKey) {+ setOpenCommandList(true);+ }+ }}+ className="block w-full rounded-md border-none px-0 text-sm text-gray-900 placeholder-gray-400 focus:outline-none focus:ring-0"+ />+ )}+ {selectedTag ? (+ <button+ onClick={(e) => {+ e.stopPropagation();+ setData({ ...data, tagId: null });+ setOpenCommandList(true);+ }}+ className="absolute inset-y-0 right-0 my-auto"+ >+ <X className="h-7 w-7 pr-3 text-gray-400" />+ </button>+ ) : (+ <ChevronDown className="absolute inset-y-0 right-0 my-auto h-7 w-7 pr-3 text-gray-400 transition-all" />+ )}</div></div>- <div className="relative">- {open && tags && tags.length > 0 ? (- <div- style={{- animationFillMode: "forwards", // to keep the last frame of the animation- }}- className="absolute z-10 h-[300px] w-full animate-input-select-slide-up overflow-auto rounded-md border border-gray-200 bg-white p-2 shadow-md transition-all sm:h-auto sm:max-h-[300px] sm:animate-input-select-slide-down"- >- <Command className="h-full overflow-auto">- {tags.map((tag) => {- return (- <Command.Item- key={tag.id}- onMouseDown={(e) => {- e.preventDefault();- e.stopPropagation();- }}- onSelect={() => {- setInputValue("");- setSelected((prev) => [...prev, tag]);- }}- className="group flex cursor-pointer items-center justify-between rounded-md px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 hover:text-gray-900 active:bg-gray-200 aria-selected:bg-gray-100 aria-selected:text-gray-900"- >- <TagBadge key={tag.id} {...tag} />- <TagPopover key={tag.id} tag={tag} />- </Command.Item>- );- })}- </Command>- </div>- ) : null}- </div>+ {openCommandList && (+ <Command.List+ style={{+ animationFillMode: "forwards", // to keep the last frame of the animation+ }}+ className="absolute z-20 h-[300px] w-full animate-input-select-slide-up overflow-auto rounded-md border border-gray-200 bg-white p-2 shadow-md transition-all sm:h-auto sm:max-h-[300px] sm:animate-input-select-slide-down"+ >+ <Command.Empty>+ <button+ type="button"+ onClick={() => setOpenCommandList(false)}+ className="flex w-full cursor-pointer items-center rounded-md bg-gray-100 px-4 py-2 text-sm text-gray-900 hover:text-gray-900 aria-selected:bg-gray-100 aria-selected:text-gray-900"+ >+ {inputValue.length > 0 ? (+ <>+ Create tag{" "}+ <span className="ml-1.5 rounded-md bg-blue-100 px-2 py-0.5 text-blue-600">+ {inputValue}+ </span>+ </>+ ) : (+ <p className="py-0.5">Start typing to create tag...</p>+ )}+ </button>+ </Command.Empty>+ {tags?.map((tag) => (+ <Command.Item+ key={tag.id}+ value={tag.name}+ onSelect={() => {+ setData({ ...data, tagId: tag.id });+ setOpenCommandList(false);+ }}+ className="group flex cursor-pointer items-center justify-between rounded-md px-4 py-2 text-sm text-gray-900 hover:bg-gray-100 hover:text-gray-900 active:bg-gray-200 aria-selected:bg-gray-100 aria-selected:text-gray-900"+ >+ <TagBadge {...tag} />+ {selectedTag?.id === tag.id && (+ <Check className="h-5 w-5 text-gray-500" />+ )}+ </Command.Item>+ ))}+ </Command.List>+ )}</Command></div>);@@ -196,10 +204,7 @@ const TagPopover = ({ tag }: { tag: TagProps }) => {) : (<Popovercontent={- <div- data-exclude-click- className="flex w-48 flex-col divide-y divide-gray-200"- >+ <div className="flex w-48 flex-col divide-y divide-gray-200"><div className="p-2"><formonClick={(e) => e.stopPropagation()} // prevent triggering <Command.Item> onClickdiff --git a/components/layout/app/settings-layout.tsx b/components/layout/app/settings-layout.tsxindex b01f2aebe9..3d9abcae0f 100644--- a/components/layout/app/settings-layout.tsx+++ b/components/layout/app/settings-layout.tsx@@ -3,7 +3,7 @@ import { useRouter } from "next/router";import AppLayout from "components/layout/app";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import { ReactNode } from "react";-import clsx from "clsx";+import { cn } from "#/lib/utils";export default function SettingsLayout({ children }: { children: ReactNode }) {const router = useRouter();@@ -45,7 +45,7 @@ export default function SettingsLayout({ children }: { children: ReactNode }) {<Linkhref={href}key={href}- className={clsx(+ className={cn("rounded-md p-2.5 text-sm transition-all duration-75 hover:bg-gray-100 active:bg-gray-200",{"font-semibold text-black": router.asPath === href,diff --git a/components/shared/popover.tsx b/components/shared/popover.tsxindex 2119e895d3..24866170bc 100644--- a/components/shared/popover.tsx+++ b/components/shared/popover.tsx@@ -2,7 +2,7 @@ import { useRouter } from "next/router";import { ReactNode, useEffect, useRef } from "react";import * as PopoverPrimitive from "@radix-ui/react-popover";import { AnimatePresence, motion, useAnimation } from "framer-motion";-import clsx from "clsx";+import { cn } from "#/lib/utils";export default function Popover({children,@@ -104,7 +104,7 @@ export default function Popover({<PopoverPrimitive.ContentsideOffset={4}align={align}- className={clsx(+ className={cn("z-40 animate-slide-up-fade items-center rounded-md border border-gray-200 bg-white drop-shadow-lg",{"hidden md:block": !desktopOnly,diff --git a/lib/utils.ts b/lib/utils.tsindex 5e2f9cb8e4..d01f4d945a 100644--- a/lib/utils.ts+++ b/lib/utils.ts@@ -1,3 +1,5 @@+import { clsx, type ClassValue } from "clsx";+import { twMerge } from "tailwind-merge";import { Metadata } from "next";import { NextRouter } from "next/router";import ms from "ms";@@ -10,6 +12,10 @@ import {} from "./constants";import { get } from "@vercel/edge-config";+export function cn(...inputs: ClassValue[]) {+ return twMerge(clsx(inputs));+}+export function constructMetadata({title = "Dub - Link Management for Modern Marketing Teams",description = "Dub is an open-source link management tool for modern marketing teams to create, share, and track short links.",diff --git a/package.json b/package.jsonindex 577dbcc78c..bc87e64eef 100644--- a/package.json+++ b/package.json@@ -77,6 +77,7 @@"sonner": "^0.5.0","stripe": "^12.7.0","swr": "^2.1.5",+ "tailwind-merge": "^1.13.2","tailwind-scrollbar-hide": "^1.1.7","tailwindcss-radix": "^2.8.0","topojson-client": "^3.1.0",diff --git a/pages/_app.tsx b/pages/_app.tsxindex 4c1b25891a..45dcb1b464 100644--- a/pages/_app.tsx+++ b/pages/_app.tsx@@ -4,7 +4,7 @@ import type { Session } from "next-auth";import { SessionProvider } from "next-auth/react";import { Toaster } from "sonner";import "@/styles/globals.css";-import clsx from "clsx";+import { cn } from "#/lib/utils";import { satoshi, inter } from "@/styles/fonts";import ModalProvider from "#/ui/modal-provider";@@ -16,7 +16,7 @@ function MyApp({<SessionProvider session={session}><Toaster /><ModalProvider>- <main className={clsx(satoshi.variable, inter.variable)}>+ <main className={cn(satoshi.variable, inter.variable)}><Component {...pageProps} /></main></ModalProvider>diff --git a/pages/api/links/[key]/tag.ts b/pages/api/links/[key]/tag.tsdeleted file mode 100644index 47774f09ec..0000000000--- a/pages/api/links/[key]/tag.ts+++ /dev/null@@ -1,75 +0,0 @@-import { randomBadgeColor } from "@/components/app/links/tag-badge";-import { withLinksAuth } from "#/lib/auth";-import prisma from "#/lib/prisma";--export default withLinksAuth(async (req, res, _session, project, domain) => {- const { key } = req.query as { key: string };- const { tag } = req.body as { tag: string };- if (!key) {- return res.status(400).end("Missing key");- }- if (!project || !domain) {- return res.status(400).end("Missing project or domain");- }- if (req.method === "POST") {- const tags = await prisma.tag.findMany({- where: {- projectId: project.id,- },- });- // if on a free plan and trying to create more than 3 tags- if (- project.plan === "free" &&- tags.length >= 3 &&- !tags.find((t) => t.name === tag)- ) {- return res- .status(403)- .end(- "You can only create 3 tags in the Free plan. Upgrade to Pro to create unlimited tags.",- );- }- const response = await prisma.link.update({- where: {- domain_key: {- domain,- key,- },- },- data: {- tag: {- connectOrCreate: {- where: {- name_projectId: {- name: tag,- projectId: project.id,- },- },- create: {- name: tag,- color: randomBadgeColor(),- projectId: project.id,- },- },- },- },- });- return res.status(200).json(response);- } else if (req.method === "DELETE") {- const response = await prisma.link.update({- where: {- domain_key: {- domain,- key,- },- },- data: {- tagId: null,- },- });- return res.status(200).json(response);- } else {- res.setHeader("Allow", ["POST", "DELETE"]);- return res.status(405).end(`Method ${req.method} Not Allowed`);- }-});diff --git a/yarn.lock b/yarn.lockindex 268d1d28d9..75e075076f 100644--- a/yarn.lock+++ b/yarn.lock@@ -8815,6 +8815,11 @@ tabbable@^6.0.1:resolved "https://registry.yarnpkg.com/tabbable/-/tabbable-6.0.1.tgz#427a09b13c83ae41eed3e88abb76a4af28bde1a6"integrity sha512-SYJSIgeyXW7EuX1ytdneO5e8jip42oHWg9xl/o3oTYhmXusZVgiA+VlPvjIN+kHii9v90AmzTZEBcsEvuAY+TA==+tailwind-merge@^1.13.2:+ version "1.13.2"+ resolved "https://registry.yarnpkg.com/tailwind-merge/-/tailwind-merge-1.13.2.tgz#1d06c9e95ffda2320efc50ed33c65be0cda23091"+ integrity sha512-R2/nULkdg1VR/EL4RXg4dEohdoxNUJGLMnWIQnPKL+O9Twu7Cn3Rxi4dlXkDzZrEGtR+G+psSXFouWlpTyLhCQ==+tailwind-scrollbar-hide@^1.1.7:version "1.1.7"resolved "https://registry.yarnpkg.com/tailwind-scrollbar-hide/-/tailwind-scrollbar-hide-1.1.7.tgz#90b481fb2e204030e3919427416650c54f56f847"