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.

fix – dynamic og, blurimage dimensions

Steven Tey3ee824448d4f
diff --git a/app/[domain]/page.tsx b/app/[domain]/page.tsx
index 452cfc291e..dcdad44353 100644
--- a/app/[domain]/page.tsx
+++ b/app/[domain]/page.tsx
@@ -1,4 +1,5 @@
import prisma from "#/lib/prisma";
+import { constructMetadata } from "#/lib/utils";
import PlaceholderContent from "./placeholder";
export async function generateMetadata({
@@ -9,20 +10,10 @@ export async function generateMetadata({
const title = `${params.domain.toUpperCase()} - A Dub.sh Custom Domain`;
const description = `${params.domain.toUpperCase()} is a custom domain on Dub - an open-source link management tool for modern marketing teams to create, share, and track short links.`;
- return {
+ return constructMetadata({
title,
description,
- openGraph: {
- title,
- description,
- },
- twitter: {
- card: "summary_large_image",
- title,
- description,
- creator: "@dubdotsh",
- },
- };
+ });
}
export async function generateStaticParams() {
diff --git a/app/dub.sh/changelog/[slug]/page.tsx b/app/dub.sh/changelog/[slug]/page.tsx
index a42bef00c0..7fe1e8617e 100644
--- a/app/dub.sh/changelog/[slug]/page.tsx
+++ b/app/dub.sh/changelog/[slug]/page.tsx
@@ -3,7 +3,7 @@ import { notFound } from "next/navigation";
import { allChangelogPosts } from "contentlayer/generated";
import { MDX } from "#/ui/blog/mdx";
import Link from "next/link";
-import { formatDate } from "#/lib/utils";
+import { constructMetadata, formatDate } from "#/lib/utils";
import { getBlurDataURL } from "#/lib/images";
import BlurImage from "#/ui/blur-image";
import Author from "#/ui/blog/author";
@@ -25,36 +25,13 @@ export async function generateMetadata({
return;
}
- const {
- title,
- publishedAt: publishedTime,
- summary: description,
- image,
- slug,
- } = post;
+ const { title, summary: description, image } = post;
- return {
- title: `${title} - Dub Changelog`,
+ return constructMetadata({
+ title,
description,
- openGraph: {
- title: `${title} - Dub Changelog`,
- description,
- type: "article",
- publishedTime,
- url: `https://dub.sh/changelog/${slug}`,
- images: [
- {
- url: image,
- },
- ],
- },
- twitter: {
- card: "summary_large_image",
- title,
- description,
- images: [image],
- },
- };
+ image,
+ });
}
export default async function ChangelogPost({
@@ -101,7 +78,7 @@ export default async function ChangelogPost({
src={post.image}
alt={post.title}
width={1200}
- height={900}
+ height={630}
priority // since it's above the fold
placeholder="blur"
blurDataURL={await getBlurDataURL(post.image!)}
diff --git a/app/dub.sh/changelog/page.tsx b/app/dub.sh/changelog/page.tsx
index 044e6c2fec..5cc6272f8e 100644
--- a/app/dub.sh/changelog/page.tsx
+++ b/app/dub.sh/changelog/page.tsx
@@ -11,7 +11,7 @@ export const metadata = constructMetadata({
title: "Changelog - Dub",
description:
"All the latest updates, improvements, and fixes to Dub - the link management tool for modern marketing teams.",
- image: "https://dub.sh/api/og/changelog",
+ image: "/api/og/changelog",
});
export default async function Changelog() {
@@ -76,7 +76,7 @@ export default async function Changelog() {
src={post.image}
alt={post.title}
width={1200}
- height={900}
+ height={630}
priority={idx === 0} // since it's above the fold
placeholder="blur"
blurDataURL={await getBlurDataURL(post.image!)}
diff --git a/lib/utils.ts b/lib/utils.ts
index 8bc3bedf13..96c79f4d9b 100644
--- a/lib/utils.ts
+++ b/lib/utils.ts
@@ -10,6 +10,7 @@ import {
ccTLDs,
SECOND_LEVEL_DOMAINS,
HOME_HOSTNAMES,
+ HOME_DOMAIN,
} from "./constants";
export function cn(...inputs: ClassValue[]) {
@@ -47,7 +48,7 @@ export function constructMetadata({
creator: "@dubdotsh",
},
icons,
- metadataBase: new URL("https://dub.sh"),
+ metadataBase: new URL(HOME_DOMAIN),
themeColor: "#FFF",
};
}