The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
added MDX components to blog post
Steven Tey7fec25ee96a1
diff --git a/app/dub.sh/(blog-post)/blog/[slug]/page.tsx b/app/dub.sh/(blog-post)/blog/[slug]/page.tsxindex ae3f39136c..85536bb0e0 100644--- a/app/dub.sh/(blog-post)/blog/[slug]/page.tsx+++ b/app/dub.sh/(blog-post)/blog/[slug]/page.tsx@@ -123,8 +123,8 @@ export default async function BlogArticle({</div>{relatedArticles.length > 0 && (<div className="flex flex-col space-y-4 py-5">- <p className="text-sm text-gray-500">Related articles</p>- <ul className="flex flex-col space-y-4 py-4">+ <p className="text-sm text-gray-500">Read more</p>+ <ul className="flex flex-col space-y-4">{relatedArticles.map((post) => (<li key={post.slug}><Link@@ -137,6 +137,9 @@ export default async function BlogArticle({<p className="line-clamp-2 text-sm text-gray-500 underline-offset-2 group-hover:underline">{post.summary}</p>+ <p className="text-xs text-gray-400 underline-offset-2 group-hover:underline">+ {formatDate(post.publishedAt)}+ </p></Link></li>))}diff --git a/app/dub.sh/blog/page.tsx b/app/dub.sh/blog/page.tsxindex ceebd36169..e0c7f17cac 100644--- a/app/dub.sh/blog/page.tsx+++ b/app/dub.sh/blog/page.tsx@@ -10,10 +10,13 @@ export const metadata = constructMetadata({export default async function Blog() {const articles = await Promise.all(- allBlogPosts.map(async (post) => ({- ...post,- blurDataURL: await getBlurDataURL(post.image),- })),+ // order by publishedAt (desc)+ allBlogPosts+ .sort((a, b) => b.publishedAt.localeCompare(a.publishedAt))+ .map(async (post) => ({+ ...post,+ blurDataURL: await getBlurDataURL(post.image),+ })),);return articles.map((article, idx) => (diff --git a/app/dub.sh/changelog/page.tsx b/app/dub.sh/changelog/page.tsxindex 07f5a5a03e..da09db4b23 100644--- a/app/dub.sh/changelog/page.tsx+++ b/app/dub.sh/changelog/page.tsx@@ -49,12 +49,7 @@ export default async function Changelog() {<div className="divide-y divide-gray-200">{allChangelogPosts- .sort((a, b) => {- if (new Date(a.publishedAt) > new Date(b.publishedAt)) {- return -1;- }- return 1;- })+ .sort((a, b) => b.publishedAt.localeCompare(a.publishedAt)).map(async (post, idx) => (<divkey={idx}diff --git a/app/dub.sh/help/page.tsx b/app/dub.sh/help/page.tsxindex 543309ef20..72b111bca3 100644--- a/app/dub.sh/help/page.tsx+++ b/app/dub.sh/help/page.tsx@@ -1,7 +1,6 @@import { constructMetadata } from "#/lib/utils";import MaxWidthWrapper from "@/components/shared/max-width-wrapper";-import { allHelpPosts } from "contentlayer/generated";-import { HELP_CATEGORIES, POPULAR_ARTICLES } from "#/lib/constants/content";+import { HELP_CATEGORIES, getPopularArticles } 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";@@ -12,16 +11,7 @@ export const metadata = constructMetadata({});export default function HelpCenter() {- const popularArticles = POPULAR_ARTICLES.map(- (slug) => allHelpPosts.find((post) => post.slug === slug)!,- );-- const categories = HELP_CATEGORIES.map((category) => ({- ...category,- postCount: allHelpPosts.filter((post) =>- post.categories.includes(category.slug),- ).length,- }));+ const popularArticles = getPopularArticles();return (<>@@ -48,7 +38,7 @@ export default function HelpCenter() {</div></div><div className="grid gap-4 sm:grid-cols-2 md:grid-cols-3">- {categories.map((category) => (+ {HELP_CATEGORIES.map((category) => (<CategoryCardkey={category.slug}href={`/help/category/${category.slug}`}diff --git a/app/ui/content/mdx.tsx b/app/ui/content/mdx.tsxindex a64b348e5c..c9233af919 100644--- a/app/ui/content/mdx.tsx+++ b/app/ui/content/mdx.tsx@@ -10,6 +10,9 @@ import useMediaQuery from "#/lib/hooks/use-media-query";import { cn } from "#/lib/utils";import Zoom from "react-medium-image-zoom";import "react-medium-image-zoom/dist/styles.css";+import { HELP_CATEGORIES, getPopularArticles } from "#/lib/constants/content";+import ArticleLink from "./article-link";+import CategoryCard from "./category-card";const CustomLink = (props: any) => {const href = props.href;@@ -39,7 +42,7 @@ const components = {),code: (props: any) => (<code- className="rounded-md bg-gray-200 px-2 py-1 font-medium text-rose-500 before:hidden after:hidden"+ className="rounded-md border border-gray-200 bg-gray-50 px-2 py-1 font-medium text-gray-600 before:hidden after:hidden"{...props}/>),@@ -57,6 +60,33 @@ const components = {{...props}/>),+ PopularArticles: () => (+ <div className="not-prose grid gap-2 rounded-xl border border-gray-200 bg-white p-4">+ {getPopularArticles().map((article) => (+ <ArticleLink key={article.slug} article={article} />+ ))}+ </div>+ ),+ HelpCategories: () => (+ <div className="not-prose grid gap-4 md:grid-cols-2 lg:grid-cols-3">+ {HELP_CATEGORIES.map((category) => (+ <CategoryCard+ key={category.slug}+ href={`/help/category/${category.slug}`}+ name={category.title}+ description={category.description}+ icon={category.icon}+ pattern={{+ y: 16,+ squares: [+ [0, 1],+ [1, 3],+ ],+ }}+ />+ ))}+ </div>+ ),};interface MDXProps {diff --git a/app/ui/home/hero.tsx b/app/ui/home/hero.tsxindex fb9b3f2d97..2051d776ff 100644--- a/app/ui/home/hero.tsx+++ b/app/ui/home/hero.tsx@@ -12,11 +12,13 @@ const Hero = () => {return (<div className="mx-auto mb-10 mt-12 max-w-md px-2.5 text-center sm:max-w-lg sm:px-0"><Link- href={`/changelog/${latestChangelog.slug}`}+ // href={`/changelog/${latestChangelog.slug}`}+ href="/blog/help-center"className="group mx-auto flex max-w-fit items-center justify-center space-x-2 overflow-hidden rounded-full border border-gray-200 bg-white px-7 py-2 shadow-[inset_10px_-50px_94px_0_rgb(199,199,199,0.1)] backdrop-blur transition-all hover:border-gray-300 hover:bg-white/50"><p className="text-sm font-semibold text-gray-700">- {latestChangelog.title}+ {/* {latestChangelog.title} */}+ Introducing the Dub Help Center</p><ExpandingArrow className="-ml-1 h-3.5 w-3.5" /></Link>diff --git a/app/ui/home/nav-mobile.tsx b/app/ui/home/nav-mobile.tsxindex 99c2b1f1e7..de1545531c 100644--- a/app/ui/home/nav-mobile.tsx+++ b/app/ui/home/nav-mobile.tsx@@ -6,6 +6,7 @@ import Link from "next/link";import { useParams } from "next/navigation";import { ReactNode, useEffect, useMemo, useRef, useState } from "react";import { navItems } from "./nav";+import { useSession } from "next-auth/react";const sidebar = {open: (height = 1000) => ({@@ -32,6 +33,7 @@ export default function MobileNav() {const [isOpen, toggleOpen] = useCycle(false, true);const containerRef = useRef(null);const { height } = useDimensions(containerRef);+ const { data: session, status } = useSession();return (<motion.nav@@ -70,24 +72,37 @@ export default function MobileNav() {</div>))}- <MenuItem key="Login">- <Link- href={`${APP_DOMAIN}/login`}- className="flex w-full font-semibold capitalize"- >- Log in- </Link>- </MenuItem>- <MenuItem className="my-3 h-px w-full bg-gray-300" />+ {session ? (+ <MenuItem key="Dashboard">+ <Link+ href={APP_DOMAIN}+ className="flex w-full font-semibold capitalize"+ >+ Dashboard+ </Link>+ </MenuItem>+ ) : status === "unauthenticated" ? (+ <>+ <MenuItem key="Login">+ <Link+ href={`${APP_DOMAIN}/login`}+ className="flex w-full font-semibold capitalize"+ >+ Log in+ </Link>+ </MenuItem>+ <MenuItem className="my-3 h-px w-full bg-gray-300" />- <MenuItem key="Signup">- <Link- href={`${APP_DOMAIN}/register`}- className="flex w-full font-semibold capitalize"- >- Sign Up- </Link>- </MenuItem>+ <MenuItem key="Signup">+ <Link+ href={`${APP_DOMAIN}/register`}+ className="flex w-full font-semibold capitalize"+ >+ Sign Up+ </Link>+ </MenuItem>+ </>+ ) : null}</motion.ul><MenuToggle toggle={toggleOpen} /></motion.nav>diff --git a/app/ui/home/nav.tsx b/app/ui/home/nav.tsxindex b44fe68f18..20eba022a9 100644--- a/app/ui/home/nav.tsx+++ b/app/ui/home/nav.tsx@@ -8,6 +8,7 @@ import MaxWidthWrapper from "@/components/shared/max-width-wrapper";import { APP_DOMAIN, SHOW_BACKGROUND_SEGMENTS } from "#/lib/constants";import va from "@vercel/analytics";import { LogoType } from "#/ui/icons";+import { useSession } from "next-auth/react";export const navItems = [{@@ -30,10 +31,10 @@ export const navItems = [export default function Nav() {const { domain = "dub.sh" } = useParams() as { domain: string };-const scrolled = useScroll(80);const selectedLayout = useSelectedLayoutSegment();const helpCenter = selectedLayout === "help";+ const { data: session, status } = useSession();return (<div@@ -63,7 +64,7 @@ export default function Nav() {><LogoType /></Link>- {helpCenter && (+ {helpCenter ? (<div className="flex items-center"><div className="mr-3 h-5 border-l-2 border-gray-400" /><Link@@ -73,68 +74,79 @@ export default function Nav() {Help Center</Link></div>+ ) : (+ <div className="hidden items-center space-x-3 lg:flex">+ {navItems.map(({ name, slug }) => (+ <Link+ id={`nav-${slug}`}+ key={slug}+ href={+ domain === "dub.sh"+ ? `/${slug}`+ : `https://dub.sh/${slug}`+ }+ {...(domain !== "dub.sh" && {+ onClick: () => {+ va.track("Referred from custom domain", {+ domain,+ medium: `navbar item (${slug})`,+ });+ },+ })}+ className={cn(+ "z-10 rounded-full px-4 py-1.5 text-sm font-medium capitalize text-gray-500 transition-colors ease-out hover:text-black",+ {+ "text-black": selectedLayout === slug,+ },+ )}+ >+ {name}+ </Link>+ ))}+ </div>)}</div>- {!helpCenter && (- <div className="hidden items-center space-x-4 lg:flex">- {navItems.map(({ name, slug }) => (+ <div className="hidden lg:block">+ {session ? (+ <Link+ href={APP_DOMAIN}+ className="animate-fade-in rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black"+ >+ Dashboard+ </Link>+ ) : status === "unauthenticated" ? (+ <><Link- id={`nav-${slug}`}- key={slug}- href={- domain === "dub.sh" ? `/${slug}` : `https://dub.sh/${slug}`- }+ href={`${APP_DOMAIN}/login`}{...(domain !== "dub.sh" && {onClick: () => {va.track("Referred from custom domain", {domain,- medium: `navbar item (${slug})`,+ medium: `navbar item (login)`,});},})}- className={cn(- "z-10 rounded-full px-4 py-1.5 text-sm font-medium capitalize text-gray-500 transition-colors ease-out hover:text-black",- {- "text-black": selectedLayout === slug,+ className="animate-fade-in rounded-full px-4 py-1.5 text-sm font-medium text-gray-500 transition-colors ease-out hover:text-black"+ >+ Log in+ </Link>+ <Link+ href={`${APP_DOMAIN}/register`}+ {...(domain !== "dub.sh" && {+ onClick: () => {+ va.track("Referred from custom domain", {+ domain,+ medium: `navbar item (signup)`,+ });},- )}+ })}+ className="animate-fade-in rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black">- {name}+ Sign Up</Link>- ))}- </div>- )}-- <div className="hidden items-center space-x-2 lg:flex">- <Link- href={`${APP_DOMAIN}/login`}- {...(domain !== "dub.sh" && {- onClick: () => {- va.track("Referred from custom domain", {- domain,- medium: `navbar item (login)`,- });- },- })}- className="rounded-full px-4 py-1.5 text-sm font-medium text-gray-500 transition-colors ease-out hover:text-black"- >- Log in- </Link>- <Link- href={`${APP_DOMAIN}/register`}- {...(domain !== "dub.sh" && {- onClick: () => {- va.track("Referred from custom domain", {- domain,- medium: `navbar item (signup)`,- });- },- })}- className="rounded-full border border-black bg-black px-4 py-1.5 text-sm text-white transition-all hover:bg-white hover:text-black"- >- Sign Up- </Link>+ </>+ ) : null}</div></div></MaxWidthWrapper>diff --git a/content/blog/help-center.mdx b/content/blog/help-center.mdxnew file mode 100644index 0000000000..8154a2b644--- /dev/null+++ b/content/blog/help-center.mdx@@ -0,0 +1,53 @@+---+title: Introducing the Dub Help Center+publishedAt: 2023-07-27+summary: Today, we're excited to launch the Dub Help Center – a one-stop shop for all your Dub-related questions.+image: https://d2vwwcvoksz7ty.cloudfront.net/blog/help-center.png+author: steventey+categories:+ - company+related:+ - introducing-dub+---++Today, we're excited to launch the [Dub Help Center](/help) – a one-stop shop for all your Dub-related questions.++Ever since we launched Dub, we've been receiving a lot of questions from our users via channels like [Crisp](https://crisp.chat/), Email, Twitter, etc. Over time, we noticed a pattern – _many of the questions were repeated_.++So we decided to build a Help Center to help our users find answers to their questions – without having to wait for us to reply.++## What's in the Help Center?++The Help Center is a collection of articles that cover the most common questions we receive from our users. It's a living knowledge base that we'll be updating regularly.++Here are some of the popular articles on the Help Center:++<PopularArticles />++We've also created categories to help you find the articles you're looking for:++<HelpCategories />++## Intuitive Search Experience – at your fingertips++The Help Center features a search bar that allows you to search for any topic you're interested in.++<Image+ alt="Fuzzy search for a typo-tolerant search experience in the Dub Help Center"+ src="https://d2vwwcvoksz7ty.cloudfront.net/blog/cmdk-search.png"+ width={1607}+ height={946}+/>++This search feature is typo-tolerant and can be accessed anywhere on Dub with the magic command `CMD+K` (or `CTRL+K` on Windows).++We're also planning to add an AI assistant to help you find answers to your questions in the future – stay tuned!++<Image+ alt="AI assistant to help you find answers to your questions"+ src="https://d2vwwcvoksz7ty.cloudfront.net/blog/ai-search.png"+ width={852}+ height={504}+/>++## What's next?diff --git a/content/blog/introducing-dub.mdx b/content/blog/introducing-dub.mdxindex 276a19cb0f..7d449d8abb 100644--- a/content/blog/introducing-dub.mdx+++ b/content/blog/introducing-dub.mdx@@ -6,6 +6,8 @@ image: https://d2vwwcvoksz7ty.cloudfront.net/blog/homepage.pngauthor: steventeycategories:- company+related:+ - help-center---Introducing Dub – an open-source link-management tool with built-in analytics and free custom domains.diff --git a/content/blog/introducing-help-center.mdx b/content/blog/introducing-help-center.mdxdeleted file mode 100644index 7eed9abf7b..0000000000--- a/content/blog/introducing-help-center.mdx+++ /dev/null@@ -1,13 +0,0 @@-----title: Introducing the Dub Help Center-publishedAt: 2023-07-27-summary: Today, we're excited to launch the Dub Help Center – a one-stop shop for all your Dub-related questions.-image: https://d2vwwcvoksz7ty.cloudfront.net/blog/help-center.png-author: steventey-categories:- - company-related:- - introducing-dub------Today, we're excited to launch the Dub Help Center – a one-stop shop for all your Dub-related questions.diff --git a/lib/constants/content.tsx b/lib/constants/content.tsxindex ed2c44f141..a754eb44e3 100644--- a/lib/constants/content.tsx+++ b/lib/constants/content.tsx@@ -1,4 +1,5 @@import { Logo } from "#/ui/icons";+import { allHelpPosts } from "contentlayer/generated";import { Globe, Link2, Settings, Webhook } from "lucide-react";export const BLOG_CATEGORIES: {@@ -74,3 +75,9 @@ export const HELP_CATEGORIES: {icon: <Webhook className="h-6 w-6 text-gray-500" />,},];++export const getPopularArticles = () => {+ return POPULAR_ARTICLES.map(+ (slug) => allHelpPosts.find((post) => post.slug === slug)!,+ );+};