The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
made responsive, improved styles
Steven Tey832e71aca6ac
diff --git a/app/dub.sh/blog/[slug]/page.tsx b/app/dub.sh/blog/[slug]/page.tsxindex fd306e7754..3034bb03e4 100644--- a/app/dub.sh/blog/[slug]/page.tsx+++ b/app/dub.sh/blog/[slug]/page.tsx@@ -1,17 +1,15 @@-import SearchButton from "#/ui/content/search-button";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import { allBlogPosts } from "contentlayer/generated";import { notFound } from "next/navigation";import Link from "next/link";import Author from "#/ui/content/author";import { MDX } from "#/ui/content/mdx";-import TableOfContents from "#/ui/content/table-of-contents";-import Feedback from "#/ui/content/feedback";import { getBlurDataURL } from "#/lib/images";import { Metadata } from "next";-import { constructMetadata } from "#/lib/utils";+import { constructMetadata, formatDate } from "#/lib/utils";import { getTweet } from "react-tweet/api";import BlurImage from "#/ui/blur-image";+import { BLOG_CATEGORIES } from "#/lib/constants/content";export async function generateStaticParams() {return allBlogPosts.map((post) => ({@@ -32,7 +30,7 @@ export async function generateMetadata({const { title, summary, image } = post;return constructMetadata({- title: `${title} | Dub Help Center`,+ title: `${title} | Dub blog`,description: summary,image,});@@ -61,6 +59,10 @@ export default async function BlogArticle({await Promise.all(data.tweetIds.map(async (id: string) => getTweet(id))),]);+ const category = BLOG_CATEGORIES.find(+ (category) => category.slug === data.categories[0],+ )!;+const relatedArticles =(data.related &&data.related.map(@@ -71,7 +73,21 @@ export default async function BlogArticle({return (<><MaxWidthWrapper>- <div className="flex max-w-screen-sm flex-col space-y-4 pt-10">+ <div className="flex max-w-screen-sm flex-col space-y-4 pt-16">+ <div className="flex items-center space-x-4">+ <Link+ href={`/blog/category/${category.slug}`}+ className="rounded-full border border-gray-200 bg-white px-4 py-1.5 text-sm font-semibold text-gray-700 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.1)] backdrop-blur transition-all hover:border-gray-300 hover:bg-white/50"+ >+ {category.title}+ </Link>+ <time+ dateTime={data.publishedAt}+ className="text-sm text-gray-500 transition-colors hover:text-gray-800"+ >+ {formatDate(data.publishedAt)}+ </time>+ </div><h1 className="font-display text-3xl font-extrabold text-gray-700 sm:text-4xl">{data.title}</h1>@@ -80,9 +96,9 @@ export default async function BlogArticle({</MaxWidthWrapper><div className="relative">- <div className="absolute top-28 h-full w-full border border-gray-200 bg-white/50 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.2)] backdrop-blur-lg" />- <MaxWidthWrapper className="grid grid-cols-4 gap-10 py-10">- <div className="relative col-span-4 mb-10 flex flex-col space-y-8 rounded-xl border border-gray-200 bg-white sm:col-span-3">+ <div className="absolute top-52 h-full w-full border border-gray-200 bg-white/50 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.2)] backdrop-blur-lg" />+ <MaxWidthWrapper className="grid grid-cols-4 gap-10 px-0 py-10">+ <div className="relative col-span-4 mb-10 flex flex-col space-y-8 bg-white sm:rounded-xl sm:border sm:border-gray-200 md:col-span-3"><BlurImageclassName="rounded-t-xl"src={data.image}@@ -96,11 +112,31 @@ export default async function BlogArticle({code={data.body.code}images={images}tweets={tweets}- className="px-6 pb-20 pt-4"+ className="px-5 pb-20 pt-4 sm:px-10"/></div>- <div className="sticky top-20 col-span-1 hidden flex-col space-y-10 divide-y divide-gray-200 self-start sm:flex">- <Author username={data.author} />+ <div className="sticky top-20 col-span-1 mt-52 hidden flex-col space-y-10 divide-y divide-gray-200 self-start sm:flex">+ <div className="flex flex-col space-y-4">+ <p className="text-sm text-gray-500">Written by</p>+ <Author username={data.author} />+ </div>+ {relatedArticles.length > 0 && (+ <div className="flex flex-col space-y-4">+ <p className="text-sm text-gray-500">Related articles</p>+ <ul className="space-y-2">+ {relatedArticles.map((post) => (+ <li key={post.slug}>+ <Link+ href={`/blog/${post.slug}`}+ className="text-gray-700 hover:text-gray-800"+ >+ {post.title}+ </Link>+ </li>+ ))}+ </ul>+ </div>+ )}</div></MaxWidthWrapper></div>diff --git a/app/dub.sh/help/article/[slug]/page.tsx b/app/dub.sh/help/article/[slug]/page.tsxindex f9dbc1a38c..1d8f8d55a5 100644--- a/app/dub.sh/help/article/[slug]/page.tsx+++ b/app/dub.sh/help/article/[slug]/page.tsx@@ -3,7 +3,7 @@ import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import { allHelpPosts } from "contentlayer/generated";import { ChevronRight } from "lucide-react";import { notFound } from "next/navigation";-import { CATEGORIES } from "#/lib/constants/content";+import { HELP_CATEGORIES } from "#/lib/constants/content";import Link from "next/link";import Author from "#/ui/content/author";import { MDX } from "#/ui/content/mdx";@@ -53,7 +53,7 @@ export default async function HelpArticle({if (!data) {notFound();}- const category = CATEGORIES.find(+ const category = HELP_CATEGORIES.find((category) => data.categories[0] === category.slug,)!;diff --git a/app/dub.sh/help/category/[slug]/page.tsx b/app/dub.sh/help/category/[slug]/page.tsxindex 567a6a8004..d27377ece6 100644--- a/app/dub.sh/help/category/[slug]/page.tsx+++ b/app/dub.sh/help/category/[slug]/page.tsx@@ -1,6 +1,6 @@import { notFound } from "next/navigation";import { allHelpPosts } from "contentlayer/generated";-import { POPULAR_ARTICLES, CATEGORIES } from "#/lib/constants/content";+import { POPULAR_ARTICLES, HELP_CATEGORIES } from "#/lib/constants/content";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import SearchButton from "#/ui/content/search-button";import Link from "next/link";@@ -10,7 +10,7 @@ import { Metadata } from "next";import { constructMetadata } from "#/lib/utils";export async function generateStaticParams() {- return CATEGORIES.map((category) => ({+ return HELP_CATEGORIES.map((category) => ({slug: category.slug,}));}@@ -20,7 +20,9 @@ export async function generateMetadata({}: {params: { slug: string };}): Promise<Metadata | undefined> {- const category = CATEGORIES.find((category) => category.slug === params.slug);+ const category = HELP_CATEGORIES.find(+ (category) => category.slug === params.slug,+ );if (!category) {return;}@@ -43,7 +45,9 @@ export default function HelpCategory({slug: string;};}) {- const data = CATEGORIES.find((category) => category.slug === params.slug);+ const data = HELP_CATEGORIES.find(+ (category) => category.slug === params.slug,+ );if (!data) {notFound();}diff --git a/app/dub.sh/help/page.tsx b/app/dub.sh/help/page.tsxindex 53f42142a5..c49e85133c 100644--- a/app/dub.sh/help/page.tsx+++ b/app/dub.sh/help/page.tsx@@ -1,7 +1,7 @@import { constructMetadata } from "#/lib/utils";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import { allHelpPosts } from "contentlayer/generated";-import { CATEGORIES, POPULAR_ARTICLES } from "#/lib/constants/content";+import { HELP_CATEGORIES, POPULAR_ARTICLES } from "#/lib/constants/content";import SearchButton from "#/ui/content/search-button";import CategoryCard from "#/ui/content/category-card";import ArticleLink from "#/ui/content/article-link";@@ -15,7 +15,7 @@ export default function HelpCenter() {(slug) => allHelpPosts.find((post) => post.slug === slug)!,);- const categories = CATEGORIES.map((category) => ({+ const categories = HELP_CATEGORIES.map((category) => ({...category,postCount: allHelpPosts.filter((post) =>post.categories.includes(category.slug),diff --git a/app/sitemap.ts b/app/sitemap.tsindex c04e917cf9..6f5bfcc6cb 100644--- a/app/sitemap.ts+++ b/app/sitemap.ts@@ -6,7 +6,7 @@ import {allLegalPosts,} from "contentlayer/generated";import { isHomeHostname } from "#/lib/utils";-import { CATEGORIES } from "#/lib/constants/content";+import { HELP_CATEGORIES } from "#/lib/constants/content";export default async function Sitemap() {const headersList = headers();@@ -47,7 +47,7 @@ export default async function Sitemap() {url: `https://${domain}/help/article/${post.slug}`,lastModified: new Date(post.updatedAt),})),- ...CATEGORIES.map((category) => ({+ ...HELP_CATEGORIES.map((category) => ({url: `https://${domain}/help/category/${category.slug}`,lastModified: new Date(),})),diff --git a/app/ui/content/author.tsx b/app/ui/content/author.tsxindex 6b5b4f39f1..2f91edda8f 100644--- a/app/ui/content/author.tsx+++ b/app/ui/content/author.tsx@@ -45,9 +45,9 @@ export default async function Author({<p className="text-sm text-gray-500">Written by {authors[username].name}</p>- <p className="text-sm font-light text-gray-400">+ <time dateTime={updatedAt} className="text-sm font-light text-gray-400">Last updated {timeAgo(new Date(updatedAt))}- </p>+ </time></div></div>) : (@@ -60,12 +60,12 @@ export default async function Author({<BlurImagesrc={authors[username].image}alt={authors[username].name}- width={48}- height={48}+ width={40}+ height={40}className="rounded-full transition-all group-hover:brightness-90"/><div className="flex flex-col">- <p className="font-bold text-gray-700">{authors[username].name}</p>+ <p className="font-semibold text-gray-700">{authors[username].name}</p><p className="text-sm text-gray-500">@{username}</p></div></Link>diff --git a/contentlayer.config.ts b/contentlayer.config.tsindex 5a2cda5560..909942bc21 100644--- a/contentlayer.config.ts+++ b/contentlayer.config.ts@@ -16,7 +16,7 @@ export const BlogPost = defineDocumentType(() => ({required: true,},publishedAt: {- type: "date",+ type: "string",required: true,},summary: {@@ -91,7 +91,7 @@ export const HelpPost = defineDocumentType(() => ({required: true,},updatedAt: {- type: "date",+ type: "string",required: true,},summary: {diff --git a/lib/constants/content.tsx b/lib/constants/content.tsxindex 207900fb0e..97095bdb34 100644--- a/lib/constants/content.tsx+++ b/lib/constants/content.tsx@@ -1,6 +1,28 @@import { Logo } from "#/ui/icons";import { Globe, Link2, Settings, Webhook } from "lucide-react";+export const BLOG_CATEGORIES: {+ title: string;+ slug: "company" | "education" | "customer-stories";+ description: string;+}[] = [+ {+ title: "Company News",+ slug: "company",+ description: "Updates and announcements from Dub.",+ },+ {+ title: "Education",+ slug: "education",+ description: "Educational content about link management.",+ },+ {+ title: "Customer Stories",+ slug: "customer-stories",+ description: "Learn how Dub customers use Dub.",+ },+];+export const POPULAR_ARTICLES = ["what-is-dub","what-is-a-project",@@ -10,7 +32,7 @@ export const POPULAR_ARTICLES = ["pro-plan",];-export const CATEGORIES: {+export const HELP_CATEGORIES: {title: string;slug:| "overview"