The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.
TypeScript clickhousemysqlnextjsopen-sourceplanetscaleprismatailwindcsstinybirdtypescriptupstashvercel
final changes, added static tweet
Steven Tey3d5b2e9f81e1
diff --git a/app/dub.sh/help/article/[slug]/page.tsx b/app/dub.sh/help/article/[slug]/page.tsxindex 76b9946de9..8f64ff84c5 100644--- a/app/dub.sh/help/article/[slug]/page.tsx+++ b/app/dub.sh/help/article/[slug]/page.tsx@@ -13,6 +13,7 @@ import ArticleLink from "#/ui/content/article-link";import { getBlurDataURL } from "#/lib/images";import { Metadata } from "next";import { constructMetadata } from "#/lib/utils";+import { getTweet } from "react-tweet/api";export async function generateStaticParams() {return allHelpPosts.map((post) => ({@@ -56,13 +57,14 @@ export default async function HelpArticle({(category) => data.categories[0] === category.slug,)!;- const [images] = await Promise.all([+ const [images, tweets] = await Promise.all([await Promise.all(data.images.map(async (src: string) => ({src,blurDataURL: await getBlurDataURL(src),})),),+ await Promise.all(data.tweetIds.map(async (id: string) => getTweet(id))),]);const relatedArticles =@@ -112,7 +114,7 @@ export default async function HelpArticle({<p className="text-gray-500">{data.summary}</p><Author username={data.author} updatedAt={data.updatedAt} /></div>- <MDX code={data.body.code} images={images} />+ <MDX code={data.body.code} images={images} tweets={tweets} />{relatedArticles.length > 0 && (<div className="flex flex-col space-y-4 border-t border-gray-200 pt-8"><h2 className="font-display text-xl font-bold sm:text-2xl">diff --git a/app/ui/content/mdx.tsx b/app/ui/content/mdx.tsxindex 25c82a96ae..2eb5855678 100644--- a/app/ui/content/mdx.tsx+++ b/app/ui/content/mdx.tsx@@ -2,9 +2,9 @@import Link from "next/link";import { useMDXComponent } from "next-contentlayer/hooks";-import Tweet from "#/ui/tweet";import GithubRepo, { GithubRepoProps } from "@/components/shared/github-repo";import BlurImage from "#/ui/blur-image";+import MDXTweet from "#/ui/tweet";import { Tweet as TweetProps } from "react-tweet/api";import useWindowSize from "#/lib/hooks/use-window-size";import { cn } from "#/lib/utils";@@ -100,10 +100,10 @@ export function MDX({ code, images, tweets, repos, className }: MDXProps) {);};- const MDXTweet = ({ id }: { id: string }) => {+ const Tweet = ({ id }: { id: string }) => {if (!tweets) return null;const tweet = tweets.find((tweet: TweetProps) => tweet.id_str === id);- return <Tweet data={tweet} />;+ return <MDXTweet data={tweet} className="mx-auto max-w-lg" noTilt />;};const MDXRepo = ({ url }: { url: string }) => {@@ -121,7 +121,12 @@ export function MDX({ code, images, tweets, repos, className }: MDXProps) {)}><Component- components={{ ...components, Image: MDXImage, MDXTweet, MDXRepo }}+ components={{+ ...components,+ Image: MDXImage,+ Tweet,+ MDXRepo,+ }}/></article>);diff --git a/app/ui/tweet.tsx b/app/ui/tweet.tsxindex 4ed56fe846..ff5e2990a9 100644--- a/app/ui/tweet.tsx+++ b/app/ui/tweet.tsx@@ -54,7 +54,7 @@ export default function Tweet({<divclassName={`${noTilt ? className : ""- } break-inside-avoid rounded-lg border border-gray-300 bg-white/20 bg-clip-padding p-6 pb-4 backdrop-blur-lg backdrop-filter`}+ } not-prose break-inside-avoid rounded-lg border border-gray-300 bg-white/20 bg-clip-padding p-6 pb-4 backdrop-blur-lg backdrop-filter`}>{/* User info, verified badge, twitter logo, text, etc. */}<div>diff --git a/content/help/how-to-create-link.mdx b/content/help/how-to-create-link.mdxindex 7956634b6d..0431607b7f 100644--- a/content/help/how-to-create-link.mdx+++ b/content/help/how-to-create-link.mdx@@ -6,7 +6,10 @@ author: steventeycategories:- link-management- getting-started+related:- how-to-use-tags+ - what-is-a-project+ - how-to-add-custom-domain---Our link builder comes with features like UTM builder, device targeting, password protection, expiration dates, and more.@@ -58,11 +61,11 @@ Inside the link builder are the following fields:3. **Choose a tag** (custom domain links only): Choose a tag to organize your links. You can learn more about tags [here](how-to-use-tags).4. **Custom Social Media Cards**: Customize how your links look when shared on social media. [Learn more](#custom-social-media-cards).5. **UTM Builder**: Add UTM parameters to your links. [Learn more](#utm-builder).-6. **Password Protection**: Protect your links with a password. [Learn more](#password-protection).-7. **Expiration Date**: Set an expiration date for your links. [Learn more](#expiration-date).-8. **iOS Targeting**: Set a custom destination URL for iOS devices. [Learn more](#ios-targeting).-9. **Android Targeting**: Set a custom destination URL for Android devices. [Learn more](#android-targeting).-10. **Social Previews**: See how your links will look when shared on social media. [Learn more](#social-previews).+6. **Password Protection**: Protect your links with a password.+7. **Expiration Date**: Set an expiration date for your links.+8. **iOS Targeting**: Set a custom destination URL for iOS devices.+9. **Android Targeting**: Set a custom destination URL for Android devices.+10. **Social Previews**: See how your links will look when shared on social media.## Custom social media cards@@ -75,8 +78,30 @@ To leverage this feature, toggle the "Custom Social Media Cards" switch in the l3. **Description**: The description that will be used for the social media card (max 240 characters).<Image- alt="The custom social media cards feature on Dub"+ alt="Create custom social media cards for your links"src="https://d2vwwcvoksz7ty.cloudfront.net/help/custom-social-media-cards.png"width={1149}height={779}/>++Here's a demo of how this feature works:++<Tweet id="1575526002570182661" />++## UTM builder++You can use the UTM builder to populate UTM parameters for your links.++- **Referral** (`ref`): The website that is sending traffic to your link.+- **UTM Source** (`utm_source`): The source of your traffic (e.g. Facebook, Twitter, etc.).+- **UTM Medium** (`utm_medium`): The medium of your traffic (e.g. social, email, etc.).+- **UTM Campaign** (`utm_campaign`): The name of your campaign (e.g. summer2023)+- **UTM Term** (`utm_term`): The term of your campaign (e.g. running+shoes)+- **UTM Content** (`utm_content`): The content of your campaign (e.g. logo+link)++<Image+ alt="Use the UTM builder to populate UTM parameters for your links"+ src="https://d2vwwcvoksz7ty.cloudfront.net/help/utm-builder.png"+ width={836}+ height={583}+/>diff --git a/contentlayer.config.ts b/contentlayer.config.tsindex aa756e7151..69401dfe3a 100644--- a/contentlayer.config.ts+++ b/contentlayer.config.ts@@ -134,9 +134,7 @@ const computedFields = (type: "changelog" | "help" | "legal") => ({tweetIds: {type: "array",resolve: (doc) => {- const tweetMatches = doc.body.raw.match(- /<StaticTweet\sid="[0-9]+"\s\/>/g,- );+ const tweetMatches = doc.body.raw.match(/<Tweet\sid="[0-9]+"\s\/>/g);return tweetMatches?.map((tweet) => tweet.match(/[0-9]+/g)[0]) || [];},},