The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
Automated changelog notifications, consolidated add-edit-link-modal components
Steven Teybb39d46d799e
diff --git a/components/app/modals/add-edit-link-modal/comments-section.tsx b/app/ui/modals/add-edit-link-modal/comments-section.tsxsimilarity index 100%rename from components/app/modals/add-edit-link-modal/comments-section.tsxrename to app/ui/modals/add-edit-link-modal/comments-section.tsxdiff --git a/app/ui/modals/add-edit-link-modal/expiration-section.tsx b/app/ui/modals/add-edit-link-modal/expiration-section.tsxindex 3307c2e0c7..e6bcf5907e 100644--- a/app/ui/modals/add-edit-link-modal/expiration-section.tsx+++ b/app/ui/modals/add-edit-link-modal/expiration-section.tsx@@ -3,8 +3,8 @@ import { type Link as LinkProps } from "@prisma/client";import { getDateTimeLocal } from "#/lib/utils";import Switch from "#/ui/switch";import { motion } from "framer-motion";+import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";-import { HOME_DOMAIN } from "#/lib/constants";export default function ExpirationSection({props,@@ -48,7 +48,7 @@ export default function ExpirationSection({<Switch fn={() => setEnabled(!enabled)} checked={enabled} /></div>{enabled && (- <motion.div className="mt-3">+ <motion.div className="mt-3" {...FADE_IN_ANIMATION_SETTINGS}><inputtype="datetime-local"id="expiresAt"diff --git a/app/ui/modals/add-edit-link-modal/geo-section.tsx b/app/ui/modals/add-edit-link-modal/geo-section.tsxnew file mode 100644index 0000000000..abe2a1a921--- /dev/null+++ b/app/ui/modals/add-edit-link-modal/geo-section.tsx@@ -0,0 +1,199 @@+import {+ Dispatch,+ SetStateAction,+ useContext,+ useEffect,+ useState,+} from "react";+import { type Link as LinkProps } from "@prisma/client";+import Switch from "#/ui/switch";+import { motion } from "framer-motion";+import {+ COUNTRIES,+ FADE_IN_ANIMATION_SETTINGS,+ HOME_DOMAIN,+} from "#/lib/constants";+import {+ InfoTooltip,+ SimpleTooltipContent,+ TooltipContent,+} from "#/ui/tooltip";+import useProject from "#/lib/swr-app/use-project";+import { ModalContext } from "#/ui/modal-provider";+import { Trash } from "lucide-react";++export default function GeoSection({+ props,+ data,+ setData,+}: {+ props?: LinkProps;+ data: LinkProps;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) {+ const { plan } = useProject();+ const { setShowUpgradePlanModal } = useContext(ModalContext);+ const { geo } = data;+ const [enabled, setEnabled] = useState(!!geo);++ useEffect(() => {+ if (enabled) {+ // if enabling, add previous geo data if exists+ setData({+ ...data,+ geo: props?.geo || {+ "": "",+ },+ });+ } else {+ // if disabling, remove geo data+ setData({ ...data, geo: null });+ }+ }, [enabled]);++ const addGeoSelector = () => {+ setData((prev) => ({+ ...prev,+ geo: { ...((prev.geo as object) || {}), "": "" }, // Add an empty entry+ }));+ };++ return (+ <div className="border-b border-gray-200 pb-5">+ <div className="flex items-center justify-between">+ <div className="flex items-center justify-between space-x-2">+ <h2 className="text-sm font-medium text-gray-900">Geo Targeting</h2>+ <InfoTooltip+ content={+ <SimpleTooltipContent+ title="Redirect your users to different links based on their location."+ cta="Learn more about geo targeting."+ href={`${HOME_DOMAIN}/help/article/how-to-create-link#geo-targeting`}+ />+ }+ />+ </div>+ <Switch+ fn={() => setEnabled(!enabled)}+ checked={enabled}+ // geo targeting is only available on Dub's Pro plan+ {...(!plan || plan === "free"+ ? {+ disabledTooltip: (+ <TooltipContent+ title="Geo targeting is only available on Dub's Pro plan. Upgrade to Pro to use this feature."+ cta="Upgrade to Pro"+ {...(plan === "free"+ ? {+ onClick: () => setShowUpgradePlanModal(true),+ }+ : {+ href: `${HOME_DOMAIN}/pricing`,+ })}+ />+ ),+ }+ : {})}+ />+ </div>+ {enabled && (+ <motion.div className="mt-3 grid gap-2" {...FADE_IN_ANIMATION_SETTINGS}>+ {geo &&+ Object.entries(geo).map(([country, url]) => (+ <GeoSelector+ key={country}+ country={country}+ url={url}+ setData={setData}+ />+ ))}+ <button+ type="button"+ onClick={addGeoSelector}+ className="mt-2 rounded-md border border-gray-200 bg-white p-1 text-sm text-gray-400 transition-all duration-75 hover:border-gray-400 hover:text-gray-500 active:bg-gray-50"+ >+ Add location+ </button>+ </motion.div>+ )}+ </div>+ );+}++const GeoSelector = ({+ country,+ url,+ setData,+}: {+ country: string;+ url: string;+ setData: Dispatch<SetStateAction<LinkProps>>;+}) => {+ const removeGeoSelector = (countryToRemove: string) => {+ setData((prev) => {+ const { [countryToRemove]: _, ...rest } = prev.geo as {+ [key: string]: string;+ };+ return {+ ...prev,+ geo: Object.keys(rest).length ? rest : null,+ };+ });+ };++ return (+ <div className="flex justify-between space-x-2">+ <div className="relative flex flex-1 rounded-md shadow-sm">+ <select+ id={`geo-selector-${country}`}+ value={country}+ onChange={(e) => {+ removeGeoSelector(country);+ setData((prev) => ({+ ...prev,+ geo: {+ ...((prev.geo as object) || {}),+ [e.target.value]: url,+ },+ }));+ }}+ className="flex w-28 items-center justify-center rounded-l-md border border-r-0 border-gray-300 bg-gray-50 pl-3 pr-7 text-center text-sm text-gray-500 focus:border-gray-300 focus:outline-none focus:ring-0"+ >+ <option value="" disabled selected={!country}>+ Country+ </option>+ {Object.entries(COUNTRIES).map(([key, value]) => (+ <option key={key} value={key}>+ {value}+ </option>+ ))}+ </select>+ <input+ type="url"+ name="geo-url"+ required+ autoComplete="off"+ className="block w-full rounded-r-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"+ value={url}+ placeholder="URL"+ onChange={(e) => {+ setData((prev) => ({+ ...prev,+ geo: {+ ...((prev.geo as object) || {}),+ [country]: e.target.value,+ },+ }));+ }}+ />+ </div>+ <button+ type="button"+ onClick={() => removeGeoSelector(country)}+ className="flex h-10 w-10 items-center justify-center rounded-md border border-gray-200 bg-white text-sm text-gray-400 transition-all duration-75 hover:border-gray-400 hover:text-gray-500 active:bg-gray-50"+ >+ <Trash size={16} className="text-gray-400" />+ </button>+ </div>+ );+};diff --git a/app/ui/modals/add-edit-link-modal/index.tsx b/app/ui/modals/add-edit-link-modal/index.tsxindex 96d7f2c8ad..2907d5c1af 100644--- a/app/ui/modals/add-edit-link-modal/index.tsx+++ b/app/ui/modals/add-edit-link-modal/index.tsx@@ -27,6 +27,7 @@ import Tooltip, { TooltipContent } from "#/ui/tooltip";import useProject from "#/lib/swr-app/use-project";import { type Link as LinkProps } from "@prisma/client";import {+ deepEqual,getApexDomain,getUrlWithoutUTMParams,linkConstructor,@@ -47,20 +48,20 @@ import punycode from "punycode/";import Button from "#/ui/button";import { ModalContext } from "#/ui/modal-provider";import RewriteSection from "./rewrite-section";+import CommentsSection from "./comments-section";+import GeoSection from "./geo-section";function AddEditLinkModal({showAddEditLinkModal,setShowAddEditLinkModal,props,duplicateProps,- hideXButton,homepageDemo,}: {showAddEditLinkModal: boolean;setShowAddEditLinkModal: Dispatch<SetStateAction<boolean>>;props?: LinkProps;duplicateProps?: LinkProps;- hideXButton?: boolean;homepageDemo?: boolean;}) {const { slug } = useParams() as { slug?: string };@@ -245,6 +246,9 @@ function AddEditLinkModal({!proxy) {return true;+ } else if (key === "geo") {+ const equalGeo = deepEqual(props.geo as object, data.geo as object);+ return equalGeo;}// Otherwise, check for discrepancy in the current key-value pairreturn data[key] === value;@@ -268,7 +272,7 @@ function AddEditLinkModal({preventDefaultClose={homepageDemo ? false : true}><div className="relative grid max-h-[80vh] divide-x divide-gray-100 overflow-scroll scrollbar-hide md:max-h-[min(906px,_90vh)] md:grid-cols-2">- {!hideXButton && !homepageDemo && (+ {!homepageDemo && (<buttononClick={() => setShowAddEditLinkModal(false)}className="group absolute right-0 top-0 z-20 m-3 hidden rounded-full p-2 text-gray-500 transition-all duration-75 hover:bg-gray-100 focus:outline-none active:bg-gray-200 md:block"@@ -519,6 +523,7 @@ function AddEditLinkModal({</div><div className="grid gap-5 px-4 md:px-16">+ <CommentsSection {...{ props, data, setData }} /><OGSection{...{ props, data, setData }}generatingMetatags={generatingMetatags}@@ -529,6 +534,7 @@ function AddEditLinkModal({<ExpirationSection {...{ props, data, setData }} /><IOSSection {...{ props, data, setData }} /><AndroidSection {...{ props, data, setData }} />+ <GeoSection {...{ props, data, setData }} /></div><div@@ -627,12 +633,10 @@ function AddEditLinkButton({export function useAddEditLinkModal({props,duplicateProps,- hideXButton,homepageDemo,}: {props?: LinkProps;duplicateProps?: LinkProps;- hideXButton?: boolean;homepageDemo?: boolean;} = {}) {const [showAddEditLinkModal, setShowAddEditLinkModal] = useState(false);@@ -645,19 +649,11 @@ export function useAddEditLinkModal({setShowAddEditLinkModal={setShowAddEditLinkModal}props={props}duplicateProps={duplicateProps}- hideXButton={hideXButton}homepageDemo={homepageDemo}/></Suspense>);- }, [- showAddEditLinkModal,- setShowAddEditLinkModal,- props,- duplicateProps,- hideXButton,- homepageDemo,- ]);+ }, [showAddEditLinkModal, setShowAddEditLinkModal]);const AddEditLinkButtonCallback = useCallback(() => {return (diff --git a/app/ui/modals/add-edit-link-modal/og-section.tsx b/app/ui/modals/add-edit-link-modal/og-section.tsxindex 8cec1d3975..f6639b2e77 100644--- a/app/ui/modals/add-edit-link-modal/og-section.tsx+++ b/app/ui/modals/add-edit-link-modal/og-section.tsx@@ -13,10 +13,10 @@ import { type Link as LinkProps } from "@prisma/client";import Switch from "#/ui/switch";import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";-import Popover from "#/ui/popover";-import UnsplashSearch from "@/components/app/modals/add-edit-link-modal/unsplash-search";import { Link2 } from "lucide-react";+import Popover from "#/ui/popover";import Unsplash from "@/components/shared/icons/unsplash";+import UnsplashSearch from "./unsplash-search";export default function OGSection({props,@@ -67,8 +67,6 @@ export default function OGSection({}}, [proxy]);- const randomIdx = Math.floor(Math.random() * 100);-const [openPopover, setOpenPopover] = useState(false);return (@@ -143,7 +141,7 @@ export default function OGSection({)}</div><label- htmlFor={`image-${randomIdx}`}+ htmlFor="image"className="group relative mt-1 flex h-[14rem] cursor-pointer flex-col items-center justify-center rounded-md border border-gray-300 bg-white shadow-sm transition-all hover:bg-gray-50">{generatingMetatags && (@@ -231,7 +229,7 @@ export default function OGSection({</label><div className="mt-1 flex rounded-md shadow-sm"><input- id={`image-${randomIdx}`}+ id="image"name="image"type="file"accept="image/*"@@ -254,7 +252,7 @@ export default function OGSection({)}<TextareaAutosizename="title"- id={`title-${randomIdx}`}+ id="title"minRows={3}maxLength={120}className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"@@ -285,7 +283,7 @@ export default function OGSection({)}<TextareaAutosizename="description"- id={`description-${randomIdx}`}+ id="description"minRows={3}maxLength={240}className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"diff --git a/components/app/modals/add-edit-link-modal/tags-section.tsx b/app/ui/modals/add-edit-link-modal/tags-section.tsxsimilarity index 99%rename from components/app/modals/add-edit-link-modal/tags-section.tsxrename to app/ui/modals/add-edit-link-modal/tags-section.tsxindex 23fb695875..dece4d75a3 100644--- a/components/app/modals/add-edit-link-modal/tags-section.tsx+++ b/app/ui/modals/add-edit-link-modal/tags-section.tsx@@ -8,7 +8,7 @@ import {} from "react";import { Check, ChevronDown, Tag, X } from "lucide-react";import { Command, useCommandState } from "cmdk";-import TagBadge from "../../links/tag-badge";+import TagBadge from "@/components/app/links/tag-badge";import { type Link as LinkProps } from "@prisma/client";import useTags from "#/lib/swr/use-tags";import { useRouter } from "next/router";diff --git a/components/app/modals/add-edit-link-modal/unsplash-search.tsx b/app/ui/modals/add-edit-link-modal/unsplash-search.tsxsimilarity index 100%rename from components/app/modals/add-edit-link-modal/unsplash-search.tsxrename to app/ui/modals/add-edit-link-modal/unsplash-search.tsxdiff --git a/app/ui/modals/add-edit-link-modal/utm-section.tsx b/app/ui/modals/add-edit-link-modal/utm-section.tsxindex 3483d0b160..e8291a88fa 100644--- a/app/ui/modals/add-edit-link-modal/utm-section.tsx+++ b/app/ui/modals/add-edit-link-modal/utm-section.tsx@@ -76,7 +76,7 @@ export default function UTMSection({<motion.div className="mt-3 grid gap-2" {...FADE_IN_ANIMATION_SETTINGS}>{paramsMetadata.map(({ display, key, examples }) => (<div key={key} className="relative mt-1 flex rounded-md shadow-sm">- <span className="flex w-60 items-center justify-center whitespace-nowrap rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-sm text-gray-500">+ <span className="flex w-60 items-center justify-center whitespace-nowrap rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-gray-500 sm:text-sm">{display}</span><inputdiff --git a/components/app/modals/add-edit-link-modal/android-section.tsx b/components/app/modals/add-edit-link-modal/android-section.tsxdeleted file mode 100644index e4d1841e8e..0000000000--- a/components/app/modals/add-edit-link-modal/android-section.tsx+++ /dev/null@@ -1,72 +0,0 @@-import { Dispatch, SetStateAction, useEffect, useState } from "react";-import { type Link as LinkProps } from "@prisma/client";-import Switch from "#/ui/switch";-import { motion } from "framer-motion";-import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";-import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";--export default function AndroidSection({- props,- data,- setData,-}: {- props?: LinkProps;- data: LinkProps;- setData: Dispatch<SetStateAction<LinkProps>>;-}) {- const { android } = data;- const [enabled, setEnabled] = useState(!!android);- useEffect(() => {- if (enabled) {- // if enabling, add previous android link if exists- setData({- ...data,- android: props?.android || android,- });- } else {- // if disabling, remove android link- setData({ ...data, android: null });- }- }, [enabled]);-- return (- <div className="border-b border-gray-200 pb-5">- <div className="flex items-center justify-between">- <div className="flex items-center justify-between space-x-2">- <h2 className="text-sm font-medium text-gray-900">- Android Targeting- </h2>- <InfoTooltip- content={- <SimpleTooltipContent- title="Redirect your Android users to a different link."- cta="Learn more about device targeting."- href={`${HOME_DOMAIN}/help/article/how-to-create-link#device-targeting-ios--android`}- />- }- />- </div>- <Switch fn={() => setEnabled(!enabled)} checked={enabled} />- </div>- {enabled && (- <motion.div- className="mt-3 flex rounded-md shadow-sm"- {...FADE_IN_ANIMATION_SETTINGS}- >- <input- name="android-url"- id="android-url"- type="url"- placeholder="https://play.google.com/store/apps/details?id=com.disney.disneyplus"- value={android || ""}- onChange={(e) => {- setData({ ...data, android: e.target.value });- }}- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"- aria-invalid="true"- />- </motion.div>- )}- </div>- );-}diff --git a/components/app/modals/add-edit-link-modal/expiration-section.tsx b/components/app/modals/add-edit-link-modal/expiration-section.tsxdeleted file mode 100644index e6bcf5907e..0000000000--- a/components/app/modals/add-edit-link-modal/expiration-section.tsx+++ /dev/null@@ -1,68 +0,0 @@-import { Dispatch, SetStateAction, useEffect, useState } from "react";-import { type Link as LinkProps } from "@prisma/client";-import { getDateTimeLocal } from "#/lib/utils";-import Switch from "#/ui/switch";-import { motion } from "framer-motion";-import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";-import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";--export default function ExpirationSection({- props,- data,- setData,-}: {- props?: LinkProps;- data: LinkProps;- setData: Dispatch<SetStateAction<LinkProps>>;-}) {- const { expiresAt } = data;- const [enabled, setEnabled] = useState(!!expiresAt);- useEffect(() => {- if (enabled) {- // if enabling, add previous expiration date if exists- setData({- ...data,- expiresAt: props?.expiresAt || expiresAt,- });- } else {- // if disabling, remove expiration date- setData({ ...data, expiresAt: null });- }- }, [enabled]);-- return (- <div className="border-b border-gray-200 pb-5">- <div className="flex items-center justify-between">- <div className="flex items-center justify-between space-x-2">- <h2 className="text-sm font-medium text-gray-900">Expiration Date</h2>- <InfoTooltip- content={- <SimpleTooltipContent- title="Set an expiration date for your links – after which it won't be accessible."- cta="Learn more."- href={`${HOME_DOMAIN}/help/article/how-to-create-link#expiration-date`}- />- }- />- </div>- <Switch fn={() => setEnabled(!enabled)} checked={enabled} />- </div>- {enabled && (- <motion.div className="mt-3" {...FADE_IN_ANIMATION_SETTINGS}>- <input- type="datetime-local"- id="expiresAt"- name="expiresAt"- min={getDateTimeLocal()}- value={expiresAt ? getDateTimeLocal(expiresAt) : ""}- step="60" // need to add step to prevent weird date bug (https://stackoverflow.com/q/19284193/10639526)- onChange={(e) => {- setData({ ...data, expiresAt: new Date(e.target.value) });- }}- className="flex w-full items-center justify-center space-x-2 rounded-md border border-gray-300 px-3 py-2 text-gray-500 shadow-sm transition-all hover:border-gray-800 focus:border-gray-800 focus:outline-none focus:ring-gray-500 sm:text-sm"- />- </motion.div>- )}- </div>- );-}diff --git a/components/app/modals/add-edit-link-modal/geo-section.tsx b/components/app/modals/add-edit-link-modal/geo-section.tsxindex 89e469adcc..0251849326 100644--- a/components/app/modals/add-edit-link-modal/geo-section.tsx+++ b/components/app/modals/add-edit-link-modal/geo-section.tsx@@ -3,7 +3,6 @@ import {SetStateAction,useContext,useEffect,- useMemo,useState,} from "react";import { type Link as LinkProps } from "@prisma/client";@@ -21,7 +20,6 @@ import {} from "#/ui/tooltip";import useProject from "#/lib/swr/use-project";import { ModalContext } from "#/ui/modal-provider";-import { cn } from "#/lib/utils";import { Trash } from "lucide-react";export default function GeoSection({@@ -85,7 +83,13 @@ export default function GeoSection({<TooltipContenttitle="Geo targeting is only available on Dub's Pro plan. Upgrade to Pro to use this feature."cta="Upgrade to Pro"- onClick={() => setShowUpgradePlanModal(true)}+ {...(plan === "free"+ ? {+ onClick: () => setShowUpgradePlanModal(true),+ }+ : {+ href: `${HOME_DOMAIN}/pricing`,+ })}/>),}@@ -127,9 +131,13 @@ const GeoSelector = ({}) => {const removeGeoSelector = (countryToRemove: string) => {setData((prev) => {- const updatedGeo = prev.geo || {};- delete updatedGeo[countryToRemove];- return { ...prev, geo: updatedGeo };+ const { [countryToRemove]: _, ...rest } = prev.geo as {+ [key: string]: string;+ };+ return {+ ...prev,+ geo: Object.keys(rest).length ? rest : null,+ };});};diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsxindex c5ea18d32f..3a572dee95 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 useProject from "#/lib/swr/use-project";import { type Link as LinkProps } from "@prisma/client";import {cn,+ deepEqual,getApexDomain,getQueryString,getUrlWithoutUTMParams,@@ -28,14 +29,6 @@ import {linkConstructor,truncate,} from "#/lib/utils";-import TagsSection from "./tags-section";-import OGSection from "./og-section";-import UTMSection from "./utm-section";-import PasswordSection from "./password-section";-import ExpirationSection from "./expiration-section";-import IOSSection from "./ios-section";-import AndroidSection from "./android-section";-import Preview from "./preview";import { DEFAULT_LINK_PROPS, GOOGLE_FAVICON_URL } from "#/lib/constants";import useDomains from "#/lib/swr/use-domains";import { toast } from "sonner";@@ -43,8 +36,16 @@ import va from "@vercel/analytics";import punycode from "punycode/";import Button from "#/ui/button";import { ModalContext } from "#/ui/modal-provider";+import TagsSection from "#/ui/modals/add-edit-link-modal/tags-section";+import OGSection from "#/ui/modals/add-edit-link-modal/og-section";+import UTMSection from "#/ui/modals/add-edit-link-modal/utm-section";+import PasswordSection from "#/ui/modals/add-edit-link-modal/password-section";+import ExpirationSection from "#/ui/modals/add-edit-link-modal/expiration-section";+import IOSSection from "#/ui/modals/add-edit-link-modal/ios-section";+import AndroidSection from "#/ui/modals/add-edit-link-modal/android-section";+import Preview from "#/ui/modals/add-edit-link-modal/preview";+import CommentsSection from "#/ui/modals/add-edit-link-modal/comments-section";import RewriteSection from "./rewrite-section";-import CommentsSection from "./comments-section";import GeoSection from "./geo-section";function AddEditLinkModal({@@ -252,6 +253,9 @@ function AddEditLinkModal({!proxy) {return true;+ } else if (key === "geo") {+ const equalGeo = deepEqual(props.geo as object, data.geo as object);+ return equalGeo;}// Otherwise, check for discrepancy in the current key-value pairreturn data[key] === value;diff --git a/components/app/modals/add-edit-link-modal/ios-section.tsx b/components/app/modals/add-edit-link-modal/ios-section.tsxdeleted file mode 100644index 8ed11e1e03..0000000000--- a/components/app/modals/add-edit-link-modal/ios-section.tsx+++ /dev/null@@ -1,70 +0,0 @@-import { Dispatch, SetStateAction, useEffect, useState } from "react";-import { type Link as LinkProps } from "@prisma/client";-import Switch from "#/ui/switch";-import { motion } from "framer-motion";-import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";-import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";--export default function IOSSection({- props,- data,- setData,-}: {- props?: LinkProps;- data: LinkProps;- setData: Dispatch<SetStateAction<LinkProps>>;-}) {- const { ios } = data;- const [enabled, setEnabled] = useState(!!ios);- useEffect(() => {- if (enabled) {- // if enabling, add previous ios link if exists- setData({- ...data,- ios: props?.ios || ios,- });- } else {- // if disabling, remove ios link- setData({ ...data, ios: null });- }- }, [enabled]);-- return (- <div className="border-b border-gray-200 pb-5">- <div className="flex items-center justify-between">- <div className="flex items-center justify-between space-x-2">- <h2 className="text-sm font-medium text-gray-900">iOS Targeting</h2>- <InfoTooltip- content={- <SimpleTooltipContent- title="Redirect your iOS users to a different link."- cta="Learn more about device targeting."- href={`${HOME_DOMAIN}/help/article/how-to-create-link#device-targeting-ios--android`}- />- }- />- </div>- <Switch fn={() => setEnabled(!enabled)} checked={enabled} />- </div>- {enabled && (- <motion.div- className="mt-3 flex rounded-md shadow-sm"- {...FADE_IN_ANIMATION_SETTINGS}- >- <input- name="ios-url"- id="ios-url"- type="url"- placeholder="https://apps.apple.com/app/1611158928"- value={ios || ""}- onChange={(e) => {- setData({ ...data, ios: e.target.value });- }}- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"- aria-invalid="true"- />- </motion.div>- )}- </div>- );-}diff --git a/components/app/modals/add-edit-link-modal/og-section.tsx b/components/app/modals/add-edit-link-modal/og-section.tsxdeleted file mode 100644index f6639b2e77..0000000000--- a/components/app/modals/add-edit-link-modal/og-section.tsx+++ /dev/null@@ -1,306 +0,0 @@-import {- Dispatch,- SetStateAction,- useCallback,- useEffect,- useState,-} from "react";-import { motion } from "framer-motion";-import TextareaAutosize from "react-textarea-autosize";-import { UploadCloud } from "@/components/shared/icons";-import { LoadingCircle } from "#/ui/icons";-import { type Link as LinkProps } from "@prisma/client";-import Switch from "#/ui/switch";-import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";-import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";-import { Link2 } from "lucide-react";-import Popover from "#/ui/popover";-import Unsplash from "@/components/shared/icons/unsplash";-import UnsplashSearch from "./unsplash-search";--export default function OGSection({- props,- data,- setData,- generatingMetatags,-}: {- props?: LinkProps;- data: LinkProps;- setData: Dispatch<SetStateAction<LinkProps>>;- generatingMetatags: boolean;-}) {- const { title, description, image, proxy } = data;-- const [fileError, setFileError] = useState<string | null>(null);- const [dragActive, setDragActive] = useState(false);-- const onChangePicture = useCallback(- (e) => {- setFileError(null);- const file = e.target.files[0];- if (file) {- if (file.size / 1024 / 1024 > 5) {- setFileError("File size too big (max 5MB)");- } else if (file.type !== "image/png" && file.type !== "image/jpeg") {- setFileError("File type not supported (.png or .jpg only)");- } else {- const reader = new FileReader();- reader.onload = (e) => {- setData((prev) => ({ ...prev, image: e.target?.result as string }));- };- reader.readAsDataURL(file);- }- }- },- [setData],- );-- useEffect(() => {- if (proxy && props) {- // if custom OG is enabled- setData((prev) => ({- ...prev,- title: props.title || title,- description: props.description || description,- image: props.image || image,- }));- }- }, [proxy]);-- const [openPopover, setOpenPopover] = useState(false);-- return (- <div className="grid gap-5 border-b border-gray-200 pb-5">- <div className="flex items-center justify-between">- <div className="flex items-center justify-between space-x-2">- <h2 className="text-sm font-medium text-gray-900">- Custom Social Media Cards- </h2>- <InfoTooltip- content={- <SimpleTooltipContent- title="Customize how your links look when shared on social media."- cta="Learn more."- href={`${HOME_DOMAIN}/help/article/how-to-create-link#custom-social-media-cards`}- />- }- />- </div>- <Switch- fn={() => setData((prev) => ({ ...prev, proxy: !proxy }))}- checked={proxy}- />- </div>-- {proxy && (- <motion.div- key="og-options"- {...FADE_IN_ANIMATION_SETTINGS}- className="grid gap-5"- >- <div>- <div className="flex items-center justify-between">- <p className="block text-sm font-medium text-gray-700">Image</p>- {fileError ? (- <p className="text-sm text-red-500">{fileError}</p>- ) : (- <div className="flex items-center justify-between">- <button- className="mr-1 flex h-6 w-6 items-center justify-center rounded-md transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200"- type="button"- onClick={() => {- const image = window.prompt(- "Paste a URL to an image (max 5MB)",- "https://",- );- if (image) {- setData((prev) => ({ ...prev, image }));- }- }}- >- <Link2 className="h-4 w-4 text-gray-500" />- </button>- <Popover- content={- <UnsplashSearch- setData={setData}- setOpenPopover={setOpenPopover}- />- }- openPopover={openPopover}- setOpenPopover={setOpenPopover}- >- <div- onClick={() => setOpenPopover(true)}- className="flex h-6 w-6 cursor-pointer items-center justify-center rounded-md transition-colors duration-75 hover:bg-gray-100 active:bg-gray-200"- >- <Unsplash className="h-3 w-3 text-gray-500" />- </div>- </Popover>- </div>- )}- </div>- <label- htmlFor="image"- className="group relative mt-1 flex h-[14rem] cursor-pointer flex-col items-center justify-center rounded-md border border-gray-300 bg-white shadow-sm transition-all hover:bg-gray-50"- >- {generatingMetatags && (- <div className="absolute z-[5] flex h-full w-full items-center justify-center rounded-md bg-white">- <LoadingCircle />- </div>- )}- <div- className="absolute z-[5] h-full w-full rounded-md"- onDragOver={(e) => {- e.preventDefault();- e.stopPropagation();- setDragActive(true);- }}- onDragEnter={(e) => {- e.preventDefault();- e.stopPropagation();- setDragActive(true);- }}- onDragLeave={(e) => {- e.preventDefault();- e.stopPropagation();- setDragActive(false);- }}- onDrop={(e) => {- e.preventDefault();- e.stopPropagation();- setDragActive(false);- setFileError(null);- const file = e.dataTransfer.files && e.dataTransfer.files[0];- if (file) {- if (file.size / 1024 / 1024 > 5) {- setFileError("File size too big (max 5MB)");- } else if (- file.type !== "image/png" &&- file.type !== "image/jpeg"- ) {- setFileError(- "File type not supported (.png or .jpg only)",- );- } else {- const reader = new FileReader();- reader.onload = (e) => {- setData((prev) => ({- ...prev,- image: e.target?.result as string,- }));- };- reader.readAsDataURL(file);- }- }- }}- />- <div- className={`${- dragActive- ? "cursor-copy border-2 border-black bg-gray-50 opacity-100"- : ""- } absolute z-[3] flex h-full w-full flex-col items-center justify-center rounded-md bg-white transition-all ${- image- ? "opacity-0 group-hover:opacity-100"- : "group-hover:bg-gray-50"- }`}- >- <UploadCloud- className={`${- dragActive ? "scale-110" : "scale-100"- } h-7 w-7 text-gray-500 transition-all duration-75 group-hover:scale-110 group-active:scale-95`}- />- <p className="mt-2 text-center text-sm text-gray-500">- Drag and drop or click to upload.- </p>- <p className="mt-2 text-center text-sm text-gray-500">- Recommended: 1200 x 630 pixels (max 5MB)- </p>- <span className="sr-only">OG image upload</span>- </div>- {image && (- <img- src={image}- alt="Preview"- className="h-full w-full rounded-md object-cover"- />- )}- </label>- <div className="mt-1 flex rounded-md shadow-sm">- <input- id="image"- name="image"- type="file"- accept="image/*"- className="sr-only"- onChange={onChangePicture}- />- </div>- </div>-- <div>- <div className="flex items-center justify-between">- <p className="block text-sm font-medium text-gray-700">Title</p>- <p className="text-sm text-gray-500">{title?.length || 0}/120</p>- </div>- <div className="relative mt-1 flex rounded-md shadow-sm">- {generatingMetatags && (- <div className="absolute flex h-full w-full items-center justify-center rounded-md border border-gray-300 bg-white">- <LoadingCircle />- </div>- )}- <TextareaAutosize- name="title"- id="title"- minRows={3}- maxLength={120}- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"- placeholder="Dub - Open Source Bitly Alternative"- value={title || ""}- onChange={(e) => {- setData({ ...data, title: e.target.value });- }}- aria-invalid="true"- />- </div>- </div>-- <div>- <div className="flex items-center justify-between">- <p className="block text-sm font-medium text-gray-700">- Description- </p>- <p className="text-sm text-gray-500">- {description?.length || 0}/240- </p>- </div>- <div className="relative mt-1 flex rounded-md shadow-sm">- {generatingMetatags && (- <div className="absolute flex h-full w-full items-center justify-center rounded-md border border-gray-300 bg-white">- <LoadingCircle />- </div>- )}- <TextareaAutosize- name="description"- id="description"- minRows={3}- maxLength={240}- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"- placeholder="Dub is open-source link management tool for modern marketing teams to create, share, and track short links."- value={description || ""}- onChange={(e) => {- setData({- ...data,- description: e.target.value,- });- }}- aria-invalid="true"- />- </div>- </div>- </motion.div>- )}- </div>- );-}diff --git a/components/app/modals/add-edit-link-modal/password-section.tsx b/components/app/modals/add-edit-link-modal/password-section.tsxdeleted file mode 100644index 9ec60fbb47..0000000000--- a/components/app/modals/add-edit-link-modal/password-section.tsx+++ /dev/null@@ -1,86 +0,0 @@-import { Dispatch, SetStateAction, useEffect, useState } from "react";-import { type Link as LinkProps } from "@prisma/client";-import Switch from "#/ui/switch";-import { motion } from "framer-motion";-import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";-import { Eye, EyeOff } from "@/components/shared/icons";-import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";--export default function PasswordSection({- props,- data,- setData,-}: {- props?: LinkProps;- data: LinkProps;- setData: Dispatch<SetStateAction<LinkProps>>;-}) {- const { password } = data;- const [enabled, setEnabled] = useState(!!password);- useEffect(() => {- if (enabled) {- // if enabling, add previous password if exists- setData({- ...data,- password: props?.password || password,- });- } else {- // if disabling, remove password- setData({ ...data, password: null });- }- }, [enabled]);-- const [showPassword, setShowPassword] = useState(false);-- return (- <div className="border-b border-gray-200 pb-5">- <div className="flex items-center justify-between">- <div className="flex items-center justify-between space-x-2">- <h2 className="text-sm font-medium text-gray-900">- Password Protection- </h2>- <InfoTooltip- content={- <SimpleTooltipContent- title="Restrict access to your short links by encrypting it with a password."- cta="Learn more."- href={`${HOME_DOMAIN}/help/article/how-to-create-link#password-protection`}- />- }- />- </div>- <Switch fn={() => setEnabled(!enabled)} checked={enabled} />- </div>- {enabled && (- <motion.div- className="relative mt-3 rounded-md shadow-sm"- {...FADE_IN_ANIMATION_SETTINGS}- >- <input- name="password"- id="password"- type={showPassword ? "text" : "password"}- className="block w-full rounded-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm"- value={password || ""}- placeholder="Enter password"- onChange={(e) => {- setData({ ...data, password: e.target.value });- }}- aria-invalid="true"- />- <button- type="button"- onClick={() => setShowPassword(!showPassword)}- className="absolute inset-y-0 right-0 flex items-center pr-3"- >- {showPassword ? (- <Eye className="h-4 w-4 text-gray-400" aria-hidden="true" />- ) : (- <EyeOff className="h-4 w-4 text-gray-400" aria-hidden="true" />- )}- </button>- </motion.div>- )}- </div>- );-}diff --git a/components/app/modals/add-edit-link-modal/preview.tsx b/components/app/modals/add-edit-link-modal/preview.tsxdeleted file mode 100644index d1ec8899ad..0000000000--- a/components/app/modals/add-edit-link-modal/preview.tsx+++ /dev/null@@ -1,196 +0,0 @@-import BlurImage from "#/ui/blur-image";-import { Facebook, LinkedIn, Photo, Twitter } from "@/components/shared/icons";-import { LoadingCircle } from "#/ui/icons";-import { type Link as LinkProps } from "@prisma/client";-import { getDomainWithoutWWW } from "#/lib/utils";-import { useMemo } from "react";-import { useDebounce } from "use-debounce";--export default function Preview({- data,- generatingMetatags,-}: {- data: LinkProps;- generatingMetatags: boolean;-}) {- const { title, description, image, url, password } = data;- const [debouncedUrl] = useDebounce(url, 500);- const hostname = useMemo(() => {- if (password) return "dub.sh";- return getDomainWithoutWWW(debouncedUrl);- }, [password, debouncedUrl]);-- const previewImage = useMemo(() => {- if (generatingMetatags) {- return (- <div className="flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300 bg-gray-100">- <LoadingCircle />- </div>- );- }- if (image) {- if (image.startsWith("https://res.cloudinary.com")) {- return (- <BlurImage- src={image}- alt="Preview"- width={1200}- height={627}- className="h-[250px] w-full border-b border-gray-300 object-cover"- />- );- } else {- return (- <img- src={image}- alt="Preview"- className="h-[250px] w-full border-b border-gray-300 object-cover"- />- );- }- } else {- return (- <div className="flex h-[250px] w-full flex-col items-center justify-center space-y-4 border-b border-gray-300 bg-gray-100">- <Photo className="h-8 w-8 text-gray-400" />- <p className="text-sm text-gray-400">- Enter a link to generate a preview.- </p>- </div>- );- }- }, [image, generatingMetatags]);-- return (- <div>- <div className="z-10 flex items-center justify-center border-b border-gray-200 bg-white px-5 py-10 sm:sticky sm:top-0">- <h2 className="text-lg font-medium">Social Previews</h2>- </div>- <div className="grid gap-5 p-5">- {/* Twitter */}- <div>- <div className="relative mb-2">- <div- className="absolute inset-0 flex items-center"- aria-hidden="true"- >- <div className="w-full border-t border-gray-200" />- </div>- <div className="relative flex justify-center">- <div className="flex items-center space-x-2 bg-white px-3">- <Twitter className="h-4 w-4 text-[#1DA1F2]" />- <p className="text-sm text-gray-400">Twitter</p>- </div>- </div>- </div>- <div className="overflow-hidden rounded-md border border-gray-300">- {previewImage}- <div className="grid gap-1 p-3">- {hostname ? (- <p className="text-sm text-[#536471]">{hostname}</p>- ) : (- <div className="mb-1 h-4 w-24 rounded-md bg-gray-100" />- )}- {title ? (- <h3 className="truncate text-sm text-[#0f1419]">{title}</h3>- ) : (- <div className="mb-1 h-4 w-full rounded-md bg-gray-100" />- )}- {description ? (- <p className="line-clamp-2 text-sm text-[#536471]">- {description}- </p>- ) : (- <div className="grid gap-2">- <div className="h-4 w-full rounded-md bg-gray-100" />- <div className="h-4 w-48 rounded-md bg-gray-100" />- </div>- )}- </div>- </div>- </div>-- {/* Facebook */}- <div>- <div className="relative mb-2">- <div- className="absolute inset-0 flex items-center"- aria-hidden="true"- >- <div className="w-full border-t border-gray-200" />- </div>- <div className="relative flex justify-center">- <div className="flex items-center space-x-2 bg-white px-3">- <Facebook className="h-4 w-4" />- <p className="text-sm text-gray-400">Facebook</p>- </div>- </div>- </div>- <div className="border border-gray-300">- {previewImage}- <div className="grid gap-1 bg-[#f2f3f5] p-3">- {hostname ? (- <p className="text-[0.8rem] uppercase text-[#606770]">- {hostname}- </p>- ) : (- <div className="mb-1 h-4 w-24 rounded-md bg-gray-200" />- )}- {title ? (- <h3 className="truncate font-semibold text-[#1d2129]">- {title}- </h3>- ) : (- <div className="mb-1 h-5 w-full rounded-md bg-gray-200" />- )}- {description ? (- <p className="line-clamp-2 text-sm text-[#606770]">- {description}- </p>- ) : (- <div className="grid gap-2">- <div className="h-4 w-full rounded-md bg-gray-200" />- <div className="h-4 w-48 rounded-md bg-gray-200" />- </div>- )}- </div>- </div>- </div>-- {/* LinkedIn */}- <div>- <div className="relative mb-2">- <div- className="absolute inset-0 flex items-center"- aria-hidden="true"- >- <div className="w-full border-t border-gray-200" />- </div>- <div className="relative flex justify-center">- <div className="flex items-center space-x-2 bg-white px-3">- <LinkedIn className="h-4 w-4" />- <p className="text-sm text-gray-400">LinkedIn</p>- </div>- </div>- </div>- <div className="overflow-hidden rounded-[2px] shadow-[0_0_0_1px_rgba(0,0,0,0.15),0_2px_3px_rgba(0,0,0,0.2)]">- {previewImage}- <div className="grid gap-1 bg-white p-3">- {title ? (- <h3 className="truncate font-semibold text-[#000000E6]">- {title}- </h3>- ) : (- <div className="mb-1 h-5 w-full rounded-md bg-gray-200" />- )}- {hostname ? (- <p className="text-xs text-[#00000099]">{hostname}</p>- ) : (- <div className="mb-1 h-4 w-24 rounded-md bg-gray-200" />- )}- </div>- </div>- </div>- </div>- </div>- );-}diff --git a/components/app/modals/add-edit-link-modal/utm-section.tsx b/components/app/modals/add-edit-link-modal/utm-section.tsxdeleted file mode 100644index e8291a88fa..0000000000--- a/components/app/modals/add-edit-link-modal/utm-section.tsx+++ /dev/null@@ -1,108 +0,0 @@-import { Dispatch, SetStateAction, useEffect, useMemo, useState } from "react";-import { type Link as LinkProps } from "@prisma/client";-import { motion } from "framer-motion";-import {- constructURLFromUTMParams,- getParamsFromURL,- paramsMetadata,- getUrlWithoutUTMParams,-} from "#/lib/utils";-import Switch from "#/ui/switch";-import { FADE_IN_ANIMATION_SETTINGS, HOME_DOMAIN } from "#/lib/constants";-import { InfoTooltip, SimpleTooltipContent } from "#/ui/tooltip";--export default function UTMSection({- props,- data,- setData,-}: {- props?: LinkProps;- data: LinkProps;- setData: Dispatch<SetStateAction<LinkProps>>;-}) {- const { url } = data;- const isValidUrl = useMemo(() => {- try {- new URL(url);- return true;- } catch (e) {- return false;- }- }, [url]);-- const params = useMemo(() => {- return getParamsFromURL(url);- }, [url]);-- const [enabled, setEnabled] = useState(- paramsMetadata.some((param) => params[param.key]),- );-- useEffect(() => {- if (enabled) {- // if enabling, add all params from props if exists && it's still the same URL- setData({- ...data,- url:- props?.url &&- getUrlWithoutUTMParams(props?.url) === getUrlWithoutUTMParams(url)- ? props?.url- : url,- });- } else {- // if disabling, remove all UTM params- setData({ ...data, url: getUrlWithoutUTMParams(url) });- }- }, [enabled]);-- return (- <div className="border-b border-gray-200 pb-5">- <div className="flex items-center justify-between">- <div className="flex items-center justify-between space-x-2">- <h2 className="text-sm font-medium text-gray-900">UTM Builder</h2>- <InfoTooltip- content={- <SimpleTooltipContent- title="Add UTM parameters to your short links for conversion tracking."- cta="Learn more."- href={`${HOME_DOMAIN}/help/article/how-to-create-link#utm-builder`}- />- }- />- </div>- <Switch fn={() => setEnabled(!enabled)} checked={enabled} />- </div>- {enabled && (- <motion.div className="mt-3 grid gap-2" {...FADE_IN_ANIMATION_SETTINGS}>- {paramsMetadata.map(({ display, key, examples }) => (- <div key={key} className="relative mt-1 flex rounded-md shadow-sm">- <span className="flex w-60 items-center justify-center whitespace-nowrap rounded-l-md border border-r-0 border-gray-300 bg-gray-50 text-gray-500 sm:text-sm">- {display}- </span>- <input- type="text"- name={key}- id={key}- disabled={!isValidUrl}- className={`${- isValidUrl ? "" : "cursor-not-allowed bg-gray-100"- } block w-full rounded-r-md border-gray-300 text-gray-900 placeholder-gray-300 focus:border-gray-500 focus:outline-none focus:ring-gray-500 sm:text-sm`}- placeholder={examples}- value={params[key] || ""}- onChange={(e) => {- setData({- ...data,- url: constructURLFromUTMParams(url, {- ...params,- [key]: e.target.value,- }),- });- }}- />- </div>- ))}- </motion.div>- )}- </div>- );-}diff --git a/components/layout/app/user-dropdown.tsx b/components/layout/app/user-dropdown.tsxindex a5a0905aef..cb7c646e8d 100644--- a/components/layout/app/user-dropdown.tsx+++ b/components/layout/app/user-dropdown.tsx@@ -1,9 +1,8 @@-import { Suspense, useContext, useEffect, useMemo, useState } from "react";+import { useContext, useEffect, useState } from "react";import { signOut, useSession } from "next-auth/react";import { Logout } from "@/components/shared/icons";import Popover from "#/ui/popover";import IconMenu from "../../shared/icon-menu";-import Image from "next/image";import va from "@vercel/analytics";import Link from "next/link";import { Edit3, HelpCircle, MessageCircle, Settings } from "lucide-react";@@ -12,8 +11,8 @@ import { LoadingCircle } from "#/ui/icons";import Badge from "#/ui/badge";import Cookies from "js-cookie";import { ModalContext } from "#/ui/modal-provider";--const latestChangelogId = "read-changelog-0715";+import { allChangelogPosts } from "contentlayer/generated";+import { HOME_DOMAIN } from "#/lib/constants";export default function UserDropdown() {const { data: session } = useSession();@@ -31,13 +30,14 @@ export default function UserDropdown() {});}, []);- const [unread, setUnread] = useState(false);+ const [unreadChangelogs, setUnreadChangelogs] = useState(0);useEffect(() => {- if (Cookies.get(latestChangelogId)) {- setUnread(false);- } else {- setUnread(true);- }+ const lastReadChangelog =+ Cookies.get("lastReadChangelog") || new Date("2023-08-13").toISOString();+ const unreadChangelogs = allChangelogPosts.filter(+ (post) => post.publishedAt > lastReadChangelog,+ ).length;+ setUnreadChangelogs(unreadChangelogs);}, []);const { setShowCMDK } = useContext(ModalContext);@@ -98,14 +98,18 @@ export default function UserDropdown() {/></Link><Link- href="https://dub.sh/changelog"+ href={`${HOME_DOMAIN}/changelog`}target="_blank"rel="noopener noreferrer"- onClick={() => Cookies.set(latestChangelogId, true)}+ onClick={() =>+ Cookies.set("lastReadChangelog", new Date().toISOString())+ }className="flex w-full justify-between rounded-md p-2 text-sm transition-all duration-75 hover:bg-gray-100 active:bg-gray-200"><IconMenu text="Changelog" icon={<Edit3 className="h-4 w-4" />} />- {unread && <Badge text="1" variant="blue" />}+ {unreadChangelogs > 0 && (+ <Badge text={`${unreadChangelogs}`} variant="blue" />+ )}</Link><buttonclassName="w-full rounded-md p-2 text-sm transition-all duration-75 hover:bg-gray-100 active:bg-gray-200"@@ -141,7 +145,7 @@ export default function UserDropdown() {) : (<div className="h-9 w-9 animate-pulse rounded-full border border-gray-300 bg-gray-100 sm:h-10 sm:w-10" />)}- {unread && (+ {unreadChangelogs > 0 && (<div className="absolute -bottom-0.5 -right-0.5 h-4 w-4 rounded-full border-2 border-white bg-blue-500" />)}</button>diff --git a/content/changelog/link-comments.mdx b/content/changelog/link-comments.mdxindex 29c51f9535..937d030aec 100644--- a/content/changelog/link-comments.mdx+++ b/content/changelog/link-comments.mdx@@ -8,4 +8,6 @@ author: "steventey"You can now use comments to add context to your short links – for you and your team.-Huge shoutout to [Alex Bass](https://twitter.com/alexhbass) from [Efficient](https://efficient.app/) for this [feature request](https://github.com/steven-tey/dub/issues/297)!+Huge shoutout to Alex for this [feature request](https://github.com/steven-tey/dub/issues/297)!++Learn more about [link comments](/help/article/how-to-create-link#comments).diff --git a/content/help/how-to-create-link.mdx b/content/help/how-to-create-link.mdxindex 041b6f1c87..234ebd433b 100644--- a/content/help/how-to-create-link.mdx+++ b/content/help/how-to-create-link.mdx@@ -69,6 +69,7 @@ Inside the link builder are the following fields:9. **Device Targeting**: Set a custom destination URL for iOS and Android devices. [Learn more](#device-targeting-ios--android).10. **Geo Targeting** (Pro plan only): Redirect your users to different links based on their location. [Learn more](#geo-targeting).11. **Social Previews**: See how your links will look when shared on social media.+12. **Comments**: Add comments to your links – for you and your team. [Learn more](#comments).## Custom social media cards@@ -217,3 +218,23 @@ To use this feature, toggle the "Geo Targeting" switch in the link builder. This/>You can also add multiple geo-targeting rules by clicking on the "Add location" button.++## Link Comments++You can add comments to your links by toggling the "Comments" switch in the link builder.++<Image+ alt="Adding comments to your links in the Dub link builder"+ src="https://d2vwwcvoksz7ty.cloudfront.net/help/comments-section.png"+ width={1370}+ height={950}+/>++When you add a comment to your link, it will be visible to you and your team as a message bubble on the link card.++<Image+ alt="Comments are visible as message bubbles on the link card"+ src="https://d2vwwcvoksz7ty.cloudfront.net/changelog/link-comments.png"+ width={1607}+ height={945}+/>diff --git a/lib/utils.ts b/lib/utils.tsindex 7b93a66b4f..466ae3a4a0 100644--- a/lib/utils.ts+++ b/lib/utils.ts@@ -467,3 +467,33 @@ export const log = async ({console.log(`Failed to log to Dub Slack. Error: ${e}`);}};++export const deepEqual = (obj1: object, obj2: object) => {+ if (obj1 === obj2) {+ return true;+ }++ if (+ typeof obj1 !== "object" ||+ typeof obj2 !== "object" ||+ obj1 === null ||+ obj2 === null+ ) {+ return false;+ }++ const keys1 = Object.keys(obj1);+ const keys2 = Object.keys(obj2);++ if (keys1.length !== keys2.length) {+ return false;+ }++ for (const key of keys1) {+ if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {+ return false;+ }+ }++ return true;+};