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.

Final tweaks

Steven Tey6c317df7330d
diff --git a/components/app/links/link-card.tsx b/components/app/links/link-card.tsx
index c1ddfd70eb..b299213ef3 100644
--- a/components/app/links/link-card.tsx
+++ b/components/app/links/link-card.tsx
@@ -107,26 +107,7 @@ export default function LinkCard({ props }: { props: LinkProps }) {
/>
<div>
<div className="flex max-w-fit items-center space-x-2">
- {domainVerified ? (
- <a
- className="w-24 truncate text-sm font-semibold text-blue-800 sm:w-full sm:text-base"
- href={linkConstructor({ key, domain })}
- target="_blank"
- rel="noreferrer"
- >
- <span className="hidden sm:block">
- {linkConstructor({ key, domain, pretty: true })}
- </span>
- <span className="sm:hidden">
- {linkConstructor({
- key,
- domain,
- pretty: true,
- noDomain: true,
- })}
- </span>
- </a>
- ) : (
+ {slug && !domainVerified ? (
<Tooltip
content={
<TooltipContent
@@ -150,6 +131,25 @@ export default function LinkCard({ props }: { props: LinkProps }) {
</span>
</div>
</Tooltip>
+ ) : (
+ <a
+ className="w-24 truncate text-sm font-semibold text-blue-800 sm:w-full sm:text-base"
+ href={linkConstructor({ key, domain })}
+ target="_blank"
+ rel="noreferrer"
+ >
+ <span className="hidden sm:block">
+ {linkConstructor({ key, domain, pretty: true })}
+ </span>
+ <span className="sm:hidden">
+ {linkConstructor({
+ key,
+ domain,
+ pretty: true,
+ noDomain: true,
+ })}
+ </span>
+ </a>
)}
<CopyButton url={linkConstructor({ key, domain })} />
<button
@@ -173,18 +173,6 @@ export default function LinkCard({ props }: { props: LinkProps }) {
<span className="ml-1 hidden sm:inline-block">clicks</span>
</p>
</Link>
- {proxy && (
- <a
- href={`https://${domain || "dub.sh"}/_proxy/${
- domain || "dub.sh"
- }/${encodeURI(key)}`}
- target="_blank"
- rel="noreferrer"
- className="group rounded-full bg-gray-100 p-1.5 transition-all duration-75 hover:scale-105 hover:bg-blue-100 active:scale-95"
- >
- <Eye className="h-3 w-3 text-gray-700 transition-all group-hover:text-blue-800" />
- </a>
- )}
</div>
<h3 className="max-w-[200px] truncate text-sm font-medium text-gray-700 md:max-w-md lg:max-w-2xl xl:max-w-3xl">
{url}
diff --git a/components/app/modals/add-edit-link-modal/index.tsx b/components/app/modals/add-edit-link-modal/index.tsx
index ea6895d125..23656c556b 100644
--- a/components/app/modals/add-edit-link-modal/index.tsx
+++ b/components/app/modals/add-edit-link-modal/index.tsx
@@ -260,10 +260,10 @@ function AddEditLinkModal({
)}
<div
- className="max-h-[min(906px,_90vh)] overflow-scroll rounded-l-2xl"
+ className="rounded-l-2xl sm:max-h-[min(906px,_90vh)] sm:overflow-scroll"
onScroll={handleScroll}
>
- <div className="sticky top-0 z-10 flex flex-col items-center justify-center space-y-3 border-b border-gray-200 bg-white px-4 pt-8 pb-8 transition-all sm:px-16">
+ <div className="z-10 flex flex-col items-center justify-center space-y-3 border-b border-gray-200 bg-white px-4 pt-8 pb-8 transition-all sm:sticky sm:top-0 sm:px-16">
<BlurImage
src={logo}
alt="Logo"
@@ -456,8 +456,8 @@ function AddEditLinkModal({
<div
className={`${
- atBottom ? "" : "shadow-[0_-20px_30px_-10px_rgba(0,0,0,0.1)]"
- } sticky bottom-0 bg-gray-50 px-4 py-8 transition-all sm:px-16`}
+ atBottom ? "" : "sm:shadow-[0_-20px_30px_-10px_rgba(0,0,0,0.1)]"
+ } bg-gray-50 px-4 py-8 transition-all sm:sticky sm:bottom-0 sm:px-16`}
>
<button
disabled={saveDisabled}
@@ -478,7 +478,7 @@ function AddEditLinkModal({
</div>
</form>
</div>
- <div className="max-h-[min(906px,_90vh)] overflow-scroll rounded-r-2xl">
+ <div className="rounded-r-2xl sm:max-h-[min(906px,_90vh)] sm:overflow-scroll">
<Preview data={data} generatingMetatags={generatingMetatags} />
</div>
</div>
diff --git a/components/app/modals/add-edit-link-modal/preview.tsx b/components/app/modals/add-edit-link-modal/preview.tsx
index 42569cf8f0..5390963395 100644
--- a/components/app/modals/add-edit-link-modal/preview.tsx
+++ b/components/app/modals/add-edit-link-modal/preview.tsx
@@ -67,10 +67,9 @@ export default function Preview({
}, [image, generatingMetatags]);
return (
- <div className="h-[1200px]">
- <div className="flex items-center justify-between border-b border-gray-200 px-5 py-10">
- <h2 className="text-lg font-medium">Preview</h2>
- <div className="flex items-center"></div>
+ <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 */}
@@ -86,7 +85,6 @@ export default function Preview({
<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>
- <ExternalLink className="h-4 w-4 text-gray-400" />
</div>
</div>
</div>
diff --git a/lib/api/links.ts b/lib/api/links.ts
index 601ab4fcc7..c9cf422a25 100644
--- a/lib/api/links.ts
+++ b/lib/api/links.ts
@@ -370,7 +370,7 @@ export async function changeDomainForLinks(
}
}
-/* Change the domain for all images on Cloudinary */
+/* Change the domain for all images for a given project on Cloudinary */
export async function changeDomainForImages(
projectId: string,
domain: string,
diff --git a/lib/utils.ts b/lib/utils.ts
index 3c8ac7cd40..16182fe531 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -258,7 +258,7 @@ export const getQueryString = (router: NextRouter) => {
};
export const truncate = (str: string, length: number) => {
- if (str.length <= length) return str;
+ if (!str || str.length <= length) return str;
return `${str.slice(0, length)}...`;
};
diff --git a/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts b/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts
index 96d27016d1..616bc1cfff 100644
--- a/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/links/[key]/archive.ts
@@ -3,12 +3,18 @@ import { archiveLink } from "@/lib/api/links";
import { withProjectAuth } from "@/lib/auth";
export default withProjectAuth(
- async (req: NextApiRequest, res: NextApiResponse, _, session) => {
+ async (req: NextApiRequest, res: NextApiResponse, project) => {
const { domain, key } = req.query as {
domain: string;
key: string;
};
+ if (domain !== project.domain) {
+ return res
+ .status(400)
+ .json({ error: "Domain does not match project domain" });
+ }
+
if (req.method === "POST") {
const response = await archiveLink(domain, key);
return res.status(200).json(response);
diff --git a/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts b/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts
index 8d845f4f5e..9711aab7cb 100644
--- a/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts
+++ b/pages/api/projects/[slug]/domains/[domain]/links/[key]/index.ts
@@ -11,7 +11,7 @@ export const config = {
};
export default withProjectAuth(
- async (req: NextApiRequest, res: NextApiResponse, _, session) => {
+ async (req: NextApiRequest, res: NextApiResponse, project) => {
const {
slug,
domain,
@@ -22,6 +22,12 @@ export default withProjectAuth(
key: string;
};
+ if (domain !== project.domain) {
+ return res
+ .status(400)
+ .json({ error: "Domain does not match project domain" });
+ }
+
// PUT /api/projects/[slug]/domains/[domain]/links/[key] - edit a link
if (req.method === "PUT") {
let { key, url } = req.body;