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.

added dynamic og image for help center posts

Steven Tey2461ce62ee79
diff --git a/app/dub.sh/help/article/[slug]/page.tsx b/app/dub.sh/help/article/[slug]/page.tsx
index a8a9fecbe7..a9a838c806 100644
--- a/app/dub.sh/help/article/[slug]/page.tsx
+++ b/app/dub.sh/help/article/[slug]/page.tsx
@@ -11,6 +11,35 @@ import TableOfContents from "#/ui/content/table-of-contents";
import Feedback from "#/ui/content/feedback";
import ArticleLink from "#/ui/content/article-link";
import { getBlurDataURL } from "#/lib/images";
+import { Metadata } from "next";
+import { constructMetadata } from "#/lib/utils";
+
+export async function generateStaticParams() {
+ return allHelpPosts.map((post) => ({
+ slug: post.slug,
+ }));
+}
+
+export async function generateMetadata({
+ params,
+}: {
+ params: { slug: string };
+}): Promise<Metadata | undefined> {
+ const post = allHelpPosts.find((post) => post.slug === params.slug);
+ if (!post) {
+ return;
+ }
+
+ const { title, summary } = post;
+
+ return constructMetadata({
+ title,
+ description: summary,
+ image: `/api/og/help?title=${encodeURIComponent(
+ title,
+ )}&summary=${encodeURIComponent(summary)}`,
+ });
+}
export default async function HelpArticle({
params,
diff --git a/pages/api/og/help.tsx b/pages/api/og/help.tsx
index 99e41c365e..f69ef1ea7d 100644
--- a/pages/api/og/help.tsx
+++ b/pages/api/og/help.tsx
@@ -1,4 +1,5 @@
/* eslint-env node */
+import { truncate } from "#/lib/utils";
import { ImageResponse } from "@vercel/og";
import { NextRequest } from "next/server";
@@ -22,10 +23,8 @@ export default async function (req: NextRequest) {
const { searchParams } = new URL(req.url);
- const hasTitle = searchParams.has("title");
- const title = hasTitle
- ? searchParams.get("title")?.slice(0, 100)
- : "Nextra Documentation";
+ const title = searchParams.get("title") || "Help Center";
+ const summary = searchParams.get("summary") || "Learn how to use Dub";
return new ImageResponse(
(
@@ -91,19 +90,6 @@ export default async function (req: NextRequest) {
fill="currentColor"
/>
</svg>
- <p
- style={{
- position: "absolute",
- bottom: 70,
- left: 80,
- margin: 0,
- fontSize: 30,
- fontFamily: "Inter Medium",
- letterSpacing: -1,
- }}
- >
- Create beautiful websites with Next.js & MDX.
- </p>
<h1
style={{
fontSize: 82,
@@ -114,12 +100,25 @@ export default async function (req: NextRequest) {
letterSpacing: -4,
backgroundImage: "linear-gradient(90deg, #fff 40%, #aaa)",
backgroundClip: "text",
- "-webkit-background-clip": "text",
+ WebkitBackgroundClip: "text",
color: "transparent",
}}
>
- {title}
+ {truncate(title, 100)}
</h1>
+ <p
+ style={{
+ position: "absolute",
+ bottom: 70,
+ left: 80,
+ margin: 0,
+ fontSize: 30,
+ fontFamily: "Inter Medium",
+ letterSpacing: -1,
+ }}
+ >
+ {truncate(summary, 140)}
+ </p>
</div>
),
{
diff --git a/posts/help/how-to-use-tags.mdx b/posts/help/how-to-use-tags.mdx
index e3fadcad45..d5775aeb04 100644
--- a/posts/help/how-to-use-tags.mdx
+++ b/posts/help/how-to-use-tags.mdx
@@ -7,4 +7,8 @@ categories:
- link-management
---
-Here's how to use tags to better manage your links on Dub.
+Tags are a great way to organize your links on Dub. You can use tags to group links together and make it easier to find them later.
+
+## What is a Tag?
+
+A tag is a label that you can assign to a link. Tags are color coded