Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

feat: refactor blog and fumadocs types

Dillion Verma58f46a1cbbcf
diff --git a/apps/www/app/(blog)/blog/[...slug]/page.tsx b/apps/www/app/(blog)/blog/[...slug]/page.tsx
index 14cce0b8..f139f3c6 100644
--- a/apps/www/app/(blog)/blog/[...slug]/page.tsx
+++ b/apps/www/app/(blog)/blog/[...slug]/page.tsx
@@ -3,23 +3,18 @@ import { SidebarCTA } from "@/components/sidebar-cta";
import { buttonVariants } from "@/components/ui/button";
import { siteConfig } from "@/config/site";
import { blogSource } from "@/lib/source";
-import { absoluteUrl } from "@/lib/utils";
+import { absoluteUrl, calculateReadingTime, formatDate } from "@/lib/utils";
import { mdxComponents } from "@/mdx-components";
import { ArrowLeftIcon } from "lucide-react";
import type { Metadata } from "next";
import Link from "next/link";
import { notFound } from "next/navigation";
+import type { BlogPosting, WithContext } from "schema-dts";
export const revalidate = false;
export const dynamic = "force-static";
export const dynamicParams = false;
-function getReadingTime(text: string): number {
- const wordsPerMinute = 200;
- const words = text.split(/\s+/).length;
- return Math.ceil(words / wordsPerMinute);
-}
-
interface PageProps {
params: Promise<{
slug: string[];
@@ -61,7 +56,6 @@ export async function generateMetadata({
url: absoluteUrl(page.url),
images: [
{
- // @ts-expect-error - revisit fumadocs types.
url: doc.image || "",
width: 1200,
height: 630,
@@ -72,7 +66,7 @@ export async function generateMetadata({
card: "summary_large_image",
title: doc.title,
description: doc.description,
- // @ts-expect-error - revisit fumadocs types.
+
images: [doc.image || ""],
creator: "@dillionverma",
},
@@ -82,65 +76,130 @@ export async function generateMetadata({
export default async function BlogPage({ params }: PageProps) {
const { doc, page } = await getDocFromParams({ params });
- // @ts-expect-error - revisit fumadocs types.
const MDX = doc.body;
+ // Generate structured data for individual blog post
+ const structuredData: WithContext<BlogPosting> = {
+ "@context": "https://schema.org",
+ "@type": "BlogPosting",
+ headline: doc.title,
+ description: doc.description,
+ url: absoluteUrl(page.url),
+ datePublished: doc.publishedOn,
+ dateModified: doc.publishedOn,
+ author: {
+ "@type": "Person",
+ name: doc.author || "Magic UI Team",
+ url: siteConfig.links?.twitter,
+ },
+ image: doc.image ? [doc.image] : undefined,
+ publisher: {
+ "@type": "Organization",
+ name: siteConfig.name,
+ url: siteConfig.url,
+ logo: {
+ "@type": "ImageObject",
+ url: `${siteConfig.url}/logo.png`,
+ },
+ },
+ mainEntityOfPage: {
+ "@type": "WebPage",
+ "@id": absoluteUrl(page.url),
+ },
+ wordCount: doc.content ? doc.content.split(/\s+/).length : 0,
+ timeRequired: `PT${calculateReadingTime(doc.content || "")}M`,
+ keywords: (() => {
+ const docTag = doc.tag;
+ if (!docTag) return undefined;
+ return Array.isArray(docTag) ? docTag : [docTag];
+ })(),
+ inLanguage: "en-US",
+ };
+
return (
- <div className="mx-auto mt-5 max-w-6xl px-5 xl:px-0">
- <div className="mb-4">
- <Link href="/blog" className={buttonVariants({ variant: "link" })}>
- <ArrowLeftIcon className="mr-2 h-4 w-4" />
- Back to Blog
- </Link>
- </div>
- <article className="mx-auto mt-5 max-w-6xl rounded-xl">
- {doc && (
- <div>
- <div className="relative overflow-hidden rounded-xl p-5 md:p-10">
- <img
- // @ts-expect-error - revisit fumadocs types.
- src={doc.image}
- alt={doc.title}
- className="size-full rounded-xl border border-border object-cover object-left"
- />
- </div>
- <div className="mx-auto flex flex-col items-center justify-center gap-y-2 border-y border-border p-5">
- <div className="mx-auto flex max-w-4xl flex-col items-center justify-center gap-y-2">
- <h1 className="text-balance text-center text-3xl font-semibold tracking-tighter md:text-5xl">
- {doc.title}
- </h1>
- <p className="text-balance text-center text-secondary-foreground md:text-lg">
- {doc.description}
- </p>
+ <>
+ <script
+ type="application/ld+json"
+ dangerouslySetInnerHTML={{
+ __html: JSON.stringify(structuredData).replace(/</g, "\\u003c"),
+ }}
+ />
+ <div className="mx-auto mt-5 max-w-6xl px-5 xl:px-0">
+ <div className="mb-4">
+ <Link href="/blog" className={buttonVariants({ variant: "link" })}>
+ <ArrowLeftIcon className="mr-2 h-4 w-4" />
+ Back to Blog
+ </Link>
+ </div>
+ <article className="mx-auto mt-5 max-w-6xl rounded-xl">
+ {doc && (
+ <div>
+ <div className="relative overflow-hidden rounded-xl p-5 md:p-10">
+ <img
+ src={doc.image}
+ alt={doc.title}
+ className="size-full rounded-xl border border-border object-cover object-left"
+ />
+ </div>
+ <div className="mx-auto flex flex-col items-center justify-center gap-y-2 border-y border-border p-5">
+ <div className="mx-auto flex max-w-4xl flex-col items-center justify-center gap-y-2">
+ <h1 className="text-balance text-center text-3xl font-semibold tracking-tighter md:text-5xl">
+ {doc.title}
+ </h1>
+ <p className="text-balance text-center text-secondary-foreground md:text-lg">
+ {doc.description}
+ </p>
+ {doc.publishedOn && (
+ <time className="text-sm text-secondary-foreground">
+ {formatDate(doc.publishedOn)}
+ </time>
+ )}
+ </div>
+ </div>
+ <div className="flex items-center justify-center gap-x-2 border-b border-border p-3 text-sm text-secondary-foreground">
+ <span>{calculateReadingTime(doc.content)} min read</span>
+ {(() => {
+ const docTag = doc.tag;
+ const tags = docTag
+ ? Array.isArray(docTag)
+ ? docTag
+ : [docTag]
+ : [];
+
+ return (
+ tags.length > 0 && (
+ <>
+ <span>·</span>
+ <div className="flex flex-wrap gap-1">
+ {tags.map((tag) => (
+ <Link
+ key={tag}
+ href={`/blog?tag=${encodeURIComponent(tag)}`}
+ className="rounded-full border border-border bg-primary/5 px-2.5 py-0.5 transition-colors hover:bg-primary/10"
+ >
+ {tag}
+ </Link>
+ ))}
+ </div>
+ </>
+ )
+ );
+ })()}
</div>
</div>
- <div className="flex items-center justify-center gap-x-2 border-b border-border p-3 text-sm text-secondary-foreground">
- {/* @ts-expect-error - revisit fumadocs types. */}
- <span>{getReadingTime(doc.content)} min read</span>
- {/* @ts-expect-error - revisit fumadocs types. */}
- {doc.tag && (
- <>
- <span>·</span>
- <span className="rounded-full border border-border bg-primary/5 px-2.5 py-0.5">
- {/* @ts-expect-error - revisit fumadocs types. */}
- {doc.tag}
- </span>
- </>
- )}
+ )}
+ <div className="grid grid-cols-1 gap-x-1 lg:grid-cols-7">
+ <div className="article-content col-span-5 p-5 lg:p-10">
+ <MDX components={mdxComponents} />
+ </div>
+ <div className="sticky top-16 col-span-2 hidden h-fit w-full flex-col items-start justify-start p-5 text-primary lg:flex ">
+ <BlogTableOfContents />
+ <div className="h-10" />
+ <SidebarCTA />
</div>
</div>
- )}
- <div className="grid grid-cols-1 gap-x-1 lg:grid-cols-7">
- <div className="article-content col-span-5 p-5 lg:p-10">
- <MDX components={mdxComponents} />
- </div>
- <div className="sticky top-16 col-span-2 hidden h-fit w-full flex-col items-start justify-start p-5 text-primary lg:flex ">
- <BlogTableOfContents />
- <div className="h-10" />
- <SidebarCTA />
- </div>
- </div>
- </article>
- </div>
+ </article>
+ </div>
+ </>
);
}
diff --git a/apps/www/app/(blog)/blog/page.tsx b/apps/www/app/(blog)/blog/page.tsx
index ce8cdeee..e82c806d 100644
--- a/apps/www/app/(blog)/blog/page.tsx
+++ b/apps/www/app/(blog)/blog/page.tsx
@@ -1,15 +1,25 @@
-import Link from "next/link";
+import { siteConfig } from "@/config/site";
import { blogSource } from "@/lib/source";
+import {
+ calculateReadingTime,
+ constructMetadata,
+ formatDate,
+ normalizeTag,
+ pluralize,
+} from "@/lib/utils";
+import type { Metadata } from "next";
+import Link from "next/link";
+import type { Blog, WithContext } from "schema-dts";
export const revalidate = false;
-export const dynamic = "force-static";
-export const dynamicParams = false;
-function calculateReadingTimeFromContent(content: string): number {
- const wordsPerMinute = 200;
- const words = content.trim().split(/\s+/).filter(Boolean).length;
- return Math.max(1, Math.ceil(words / wordsPerMinute));
-}
+const BLOG_DESCRIPTION =
+ "Latest articles about UI components, animations, and web development best practices.";
+
+export const metadata: Metadata = constructMetadata({
+ title: `Blog | ${siteConfig.name}`,
+ description: BLOG_DESCRIPTION,
+});
export default async function Page({
searchParams,
@@ -17,107 +27,201 @@ export default async function Page({
searchParams?: Promise<{ tag?: string }>;
}) {
const params = await searchParams;
- const posts = blogSource.getPages();
-
const selectedTag = params?.tag ?? "";
- const tags = Array.from(
- new Set(
- // @ts-expect-error - revisit fumadocs types.
- posts.map((p) => p.data?.tag).filter(Boolean),
- ),
- ) as string[];
- tags.sort((a, b) => a.localeCompare(b));
+ const posts = blogSource.getPages().sort((a, b) => {
+ const dateA = new Date(a.data?.publishedOn || 0).getTime();
+ const dateB = new Date(b.data?.publishedOn || 0).getTime();
+ return dateB - dateA;
+ });
+
+ const allTags = posts.flatMap((p) => normalizeTag(p.data?.tag));
+ const tags = [...new Set(allTags)].filter(Boolean).sort();
const filteredPosts = selectedTag
- ? posts.filter(
- // @ts-expect-error - revisit fumadocs types.
- (p) => p.data?.tag === selectedTag,
- )
+ ? posts.filter((p) => normalizeTag(p.data?.tag).includes(selectedTag))
: posts;
+ // Generate structured data
+ const structuredData: WithContext<Blog> = {
+ "@context": "https://schema.org",
+ "@type": "Blog",
+ name: `${siteConfig.name} Blog`,
+ description: BLOG_DESCRIPTION,
+ url: `${siteConfig.url}/blog`,
+ inLanguage: "en-US",
+ publisher: {
+ "@type": "Organization",
+ name: siteConfig.name,
+ url: siteConfig.url,
+ logo: {
+ "@type": "ImageObject",
+ url: `${siteConfig.url}/icon.png`,
+ },
+ },
+ blogPost: filteredPosts.slice(0, 10).map((post) => ({
+ "@type": "BlogPosting",
+ headline: post.data?.title,
+ description: post.data?.description,
+ url: `${siteConfig.url}${post.url}`,
+ datePublished: post.data?.publishedOn,
+ dateModified: post.data?.publishedOn,
+ author: {
+ "@type": "Person",
+ name: post.data?.author,
+ url: siteConfig.links?.twitter,
+ },
+ image: post.data?.image ? [post.data?.image] : undefined,
+ keywords:
+ normalizeTag(post.data?.tag).length > 0
+ ? normalizeTag(post.data?.tag)
+ : undefined,
+ publisher: {
+ "@type": "Organization",
+ name: siteConfig.name,
+ url: siteConfig.url,
+ },
+ })),
+ };
+
return (
- <main className="mx-auto w-full max-w-6xl p-6">
- <h1 className="mb-4 text-2xl font-semibold tracking-tight">Blog</h1>
+ <>
+ <script
+ type="application/ld+json"
+ dangerouslySetInnerHTML={{
+ __html: JSON.stringify(structuredData).replace(/</g, "\\u003c"),
+ }}
+ />
+ <main className="mx-auto w-full max-w-6xl px-6 py-8">
+ <header className="mb-8 space-y-4">
+ <div>
+ <h1 className="text-3xl font-bold tracking-tight">Blog</h1>
+ <p className="mt-2 text-lg text-muted-foreground">
+ {BLOG_DESCRIPTION}
+ </p>
+ </div>
- {tags.length > 0 ? (
- <nav className="mb-6 flex flex-wrap gap-2">
- <Link
- href="/blog"
- className={`rounded-full border px-3 py-1 text-sm ${
- selectedTag === ""
- ? "bg-primary text-primary-foreground"
- : "text-muted-foreground hover:bg-muted"
- }`}
- >
- All
- </Link>
- {tags.map((tag) => (
- <Link
- key={tag}
- href={`/blog?tag=${encodeURIComponent(tag)}`}
- className={`rounded-full border px-3 py-1 text-sm ${
- selectedTag === tag
- ? "bg-primary text-primary-foreground"
- : "text-muted-foreground hover:bg-muted"
- }`}
- >
- {tag}
- </Link>
- ))}
- </nav>
- ) : null}
+ {filteredPosts.length > 0 && (
+ <p className="text-sm text-muted-foreground">
+ {selectedTag
+ ? `${pluralize(filteredPosts.length, "article")} tagged with "${selectedTag}"`
+ : `${pluralize(filteredPosts.length, "article")} total`}
+ </p>
+ )}
+ </header>
- {filteredPosts.length === 0 ? (
- <p className="text-muted-foreground">No posts yet.</p>
- ) : (
- <ul className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3">
- {filteredPosts.map((post) => {
- // @ts-expect-error - revisit fumadocs types.
- const image = post.data?.image as string | undefined;
- const title = (post.data?.title as string | undefined) ?? post.url;
- const description = post.data?.description as string | undefined;
- // @ts-expect-error - revisit fumadocs types.
- const tag = post.data?.tag as string | undefined;
- // @ts-expect-error - revisit fumadocs types.
- const content = (post.data?.content as string | undefined) ?? "";
- const readingTime = calculateReadingTimeFromContent(content);
+ {tags.length > 0 && (
+ <nav className="mb-8">
+ <div className="flex flex-wrap gap-2">
+ <Link
+ href="/blog"
+ className={`rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${
+ !selectedTag
+ ? "bg-primary text-primary-foreground"
+ : "text-muted-foreground hover:bg-muted hover:text-foreground"
+ }`}
+ >
+ All
+ </Link>
+ {tags.map((tag) => (
+ <Link
+ key={tag}
+ href={`/blog?tag=${encodeURIComponent(tag)}`}
+ className={`rounded-full border px-3 py-1.5 text-sm font-medium transition-colors ${
+ selectedTag === tag
+ ? "bg-primary text-primary-foreground"
+ : "text-muted-foreground hover:bg-muted hover:text-foreground"
+ }`}
+ >
+ {tag}
+ </Link>
+ ))}
+ </div>
+ </nav>
+ )}
+
+ {filteredPosts.length === 0 ? (
+ <div className="py-16 text-center">
+ <p className="text-lg text-muted-foreground">
+ {selectedTag
+ ? `No articles found for "${selectedTag}".`
+ : "No posts yet."}
+ </p>
+ {selectedTag && (
+ <Link
+ href="/blog"
+ className="mt-4 inline-flex items-center text-primary hover:underline"
+ >
+ View all articles
+ </Link>
+ )}
+ </div>
+ ) : (
+ <div className="grid gap-6 sm:grid-cols-2 lg:grid-cols-3">
+ {filteredPosts.map((post) => (
+ <article
+ key={post.url}
+ className="group flex flex-col overflow-hidden rounded-xl border bg-card transition-all duration-200 hover:bg-accent/5"
+ >
+ <Link href={post.url} className="flex flex-col h-full">
+ {post.data?.image && (
+ <div className="aspect-video overflow-hidden">
+ <img
+ src={post.data.image}
+ alt={post.data?.title ?? post.url}
+ width={640}
+ height={360}
+ className="h-full w-full object-cover"
+ />
+ </div>
+ )}
- return (
- <li key={post.url} className="overflow-hidden rounded-md border">
- <Link href={post.url} className="block">
- {image ? (
- <img
- src={image}
- alt={title}
- width={640}
- height={360}
- className="h-40 w-full object-cover"
- />
- ) : null}
- <div className="space-y-2 p-4">
- <h2 className="line-clamp-2 font-medium leading-tight underline-offset-2 hover:underline">
- {title}
- </h2>
- {description ? (
- <p className="line-clamp-2 text-sm text-muted-foreground">
- {description}
- </p>
- ) : null}
- <div className="flex items-center gap-2 text-xs text-muted-foreground">
- {tag ? (
- <span className="rounded-full border px-2 py-0.5">
- {tag}
+ <div className="flex flex-col flex-1 p-6 space-y-4">
+ <div className="flex-1 space-y-2">
+ <h2 className="line-clamp-2 text-xl font-semibold leading-tight group-hover:text-primary transition-colors">
+ {post.data?.title ?? post.url}
+ </h2>
+ {post.data?.description && (
+ <p className="line-clamp-3 text-sm text-muted-foreground leading-relaxed">
+ {post.data.description}
+ </p>
+ )}
+ </div>
+
+ <div className="flex flex-col gap-2 text-xs text-muted-foreground">
+ <div className="flex items-center gap-2">
+ {post.data?.publishedOn && (
+ <time dateTime={post.data.publishedOn}>
+ {formatDate(post.data.publishedOn)}
+ </time>
+ )}
+ {post.data?.publishedOn && <span>·</span>}
+ <span>
+ {calculateReadingTime(post.data?.content ?? "")} min
+ read
</span>
- ) : null}
- <span>{readingTime} min read</span>
+ </div>
+
+ {normalizeTag(post.data?.tag).length > 0 && (
+ <div className="flex flex-wrap gap-1">
+ {normalizeTag(post.data.tag).map((tag) => (
+ <Link
+ key={tag}
+ href={`/blog?tag=${encodeURIComponent(tag)}`}
+ className="rounded-md border px-2 py-1 text-xs transition-colors hover:bg-accent"
+ >
+ {tag}
+ </Link>
+ ))}
+ </div>
+ )}
</div>
</div>
</Link>
- </li>
- );
- })}
- </ul>
- )}
- </main>
+ </article>
+ ))}
+ </div>
+ )}
+ </main>
+ </>
);
}
diff --git a/apps/www/app/(docs)/docs/[[...slug]]/page.tsx b/apps/www/app/(docs)/docs/[[...slug]]/page.tsx
index 0c1acb69..4795091b 100644
--- a/apps/www/app/(docs)/docs/[[...slug]]/page.tsx
+++ b/apps/www/app/(docs)/docs/[[...slug]]/page.tsx
@@ -1,24 +1,23 @@
+import { DocsCopyPage } from "@/components/docs-copy-page";
import { Badge } from "@/components/ui/badge";
import { absoluteUrl } from "@/lib/utils";
-import { DocsCopyPage } from "@/components/docs-copy-page";
-import type { Metadata } from "next";
-import Link from "next/link";
-import { notFound } from "next/navigation";
-import { DocsTableOfContents } from "@/components/docs-toc";
import { Contribute } from "@/components/contribute";
+import { DocsTableOfContents } from "@/components/docs-toc";
import { SidebarCTA } from "@/components/sidebar-cta";
+import { Button } from "@/components/ui/button";
+import { replaceComponentSource } from "@/lib/docs";
+import { source } from "@/lib/source";
+import { mdxComponents } from "@/mdx-components";
import {
IconArrowLeft,
IconArrowRight,
IconArrowUpRight,
} from "@tabler/icons-react";
-import { Button } from "@/components/ui/button";
-import { source } from "@/lib/source";
-import { mdxComponents } from "@/mdx-components";
import { findNeighbour } from "fumadocs-core/server";
-import { siteConfig } from "@/config/site";
-import { replaceComponentSource } from "@/lib/docs";
+import type { Metadata } from "next";
+import Link from "next/link";
+import { notFound } from "next/navigation";
export const revalidate = false;
export const dynamic = "force-static";
@@ -89,12 +88,8 @@ export async function generateMetadata({
export default async function DocPage({ params }: DocPageProps) {
const { doc, page } = await getDocFromParams({ params });
-
- // @ts-expect-error - revisit fumadocs types.
const MDX = doc.body;
const neighbours = findNeighbour(source.pageTree, page.url);
-
- // @ts-expect-error - revisit fumadocs types.
const links = doc.links;
return (
@@ -113,7 +108,6 @@ export default async function DocPage({ params }: DocPageProps) {
</h1>
<div className="docs-nav bg-background/80 border-border/50 fixed inset-x-0 bottom-0 isolate z-50 flex items-center gap-2 border-t px-6 py-4 backdrop-blur-sm sm:static sm:z-0 sm:border-t-0 sm:bg-transparent sm:px-0 sm:pt-1.5 sm:backdrop-blur-none">
<DocsCopyPage
- // @ts-expect-error - revisit fumadocs types.
page={await replaceComponentSource(doc.content)}
url={absoluteUrl(page.url)}
/>
@@ -203,10 +197,8 @@ export default async function DocPage({ params }: DocPageProps) {
</div>
<div className="sticky top-[calc(var(--header-height)+1px)] z-30 ml-auto hidden h-[calc(100svh-var(--footer-height)+2rem)] w-84 flex-col gap-4 overflow-hidden overscroll-none pb-8 xl:flex">
<div className="h-(--top-spacing) shrink-0" />
- {/* @ts-expect-error - revisit fumadocs types. */}
{doc.toc?.length ? (
<div className="no-scrollbar overflow-y-auto px-8">
- {/* @ts-expect-error - revisit fumadocs types. */}
<DocsTableOfContents toc={doc.toc} />
<Contribute page={page} />
<div className="h-8" />
diff --git a/apps/www/app/(marketing)/showcase/[...slug]/page.tsx b/apps/www/app/(marketing)/showcase/[...slug]/page.tsx
index 6a94b0c5..21b38aa9 100644
--- a/apps/www/app/(marketing)/showcase/[...slug]/page.tsx
+++ b/apps/www/app/(marketing)/showcase/[...slug]/page.tsx
@@ -1,5 +1,4 @@
import { ShowcaseCard } from "@/components/sections/showcase";
-import { siteConfig } from "@/config/site";
import { showcaseSource } from "@/lib/source";
import { absoluteUrl } from "@/lib/utils";
@@ -86,9 +85,7 @@ export default async function PagePage({ params }: PageProps) {
<ShowcaseCard
title={doc.title ?? ""}
href={page.url}
- // @ts-expect-error - revisit fumadocs types.
image={doc.image ?? ""}
- // @ts-expect-error - revisit fumadocs types.
affiliation={doc.affiliation ?? ""}
/>
</article>
diff --git a/apps/www/app/(marketing)/showcase/page.tsx b/apps/www/app/(marketing)/showcase/page.tsx
index 7f4cf7ea..aa784b0b 100644
--- a/apps/www/app/(marketing)/showcase/page.tsx
+++ b/apps/www/app/(marketing)/showcase/page.tsx
@@ -1,5 +1,5 @@
-import { showcaseSource } from "@/lib/source";
import { ShowcaseCard } from "@/components/sections/showcase";
+import { showcaseSource } from "@/lib/source";
import { BlurFade } from "@/registry/magicui/blur-fade";
export default function Page() {
@@ -19,9 +19,7 @@ export default function Page() {
{...showcase}
href={showcase.url}
title={showcase.data.title ?? ""}
- // @ts-expect-error - revisit fumadocs types.
image={showcase.data.image ?? ""}
- // @ts-expect-error - revisit fumadocs types.
affiliation={showcase.data.affiliation ?? ""}
/>
</BlurFade>
diff --git a/apps/www/app/llm/[[...slug]]/route.ts b/apps/www/app/llm/[[...slug]]/route.ts
index 5e30ee28..c948f785 100644
--- a/apps/www/app/llm/[[...slug]]/route.ts
+++ b/apps/www/app/llm/[[...slug]]/route.ts
@@ -1,7 +1,7 @@
+import { replaceComponentSource } from "@/lib/docs";
+import { source } from "@/lib/source";
import { notFound } from "next/navigation";
import { NextResponse, type NextRequest } from "next/server";
-import { source } from "@/lib/source";
-import { replaceComponentSource } from "@/lib/docs";
export const revalidate = false;
@@ -16,7 +16,6 @@ export async function GET(
notFound();
}
- // @ts-expect-error - revisit fumadocs types.
let mdx = page.data.content as string;
// Replace component tags with actual source code
diff --git a/apps/www/app/sitemap.ts b/apps/www/app/sitemap.ts
index 1c226888..3c6094b0 100644
--- a/apps/www/app/sitemap.ts
+++ b/apps/www/app/sitemap.ts
@@ -16,12 +16,10 @@ export default async function sitemap(): Promise<MetadataRoute.Sitemap> {
},
...allDocs.map((post) => ({
url: `${protocol}://${domain}${post.url}`,
- // @ts-expect-error - revisit fumadocs types.
lastModified: post.data.date,
})),
...allBlogs.map((post) => ({
url: `${protocol}://${domain}${post.url}`,
- // @ts-expect-error - revisit fumadocs types.
lastModified: post.data.publishedOn,
})),
];
diff --git a/apps/www/components/sections/component-demos.tsx b/apps/www/components/sections/component-demos.tsx
index 23891093..a2b01832 100644
--- a/apps/www/components/sections/component-demos.tsx
+++ b/apps/www/components/sections/component-demos.tsx
@@ -12,7 +12,6 @@ export function ComponentDemos() {
notFound();
}
- // @ts-expect-error - revisit fumadocs types.
const MDX = page.data.body;
return (
diff --git a/apps/www/components/sections/showcase.tsx b/apps/www/components/sections/showcase.tsx
index 02cf68bb..5b63148a 100644
--- a/apps/www/components/sections/showcase.tsx
+++ b/apps/www/components/sections/showcase.tsx
@@ -1,5 +1,5 @@
-import { ChevronRightIcon } from "@radix-ui/react-icons";
import { showcaseSource } from "@/lib/source";
+import { ChevronRightIcon } from "@radix-ui/react-icons";
import Link from "next/link";
import { Marquee } from "@/registry/magicui/marquee";
@@ -53,7 +53,6 @@ export function Showcase() {
<div className="relative flex flex-col">
<Marquee className="max-w-screen [--duration:40s]">
{showcases
- // @ts-expect-error - revisit fumadocs types.
.filter((showcase) => showcase.data.featured)
.map((showcase, idx) => (
<ShowcaseCard
@@ -61,9 +60,7 @@ export function Showcase() {
{...showcase}
href={showcase.url}
title={showcase.data.title ?? ""}
- // @ts-expect-error - revisit fumadocs types.
affiliation={showcase.data.affiliation ?? ""}
- // @ts-expect-error - revisit fumadocs types.
image={showcase.data.image ?? ""}
/>
))}
diff --git a/apps/www/content/blog/tailwind-css-component-library.mdx b/apps/www/content/blog/tailwind-css-component-library.mdx
index 2dc760c9..69b94b40 100644
--- a/apps/www/content/blog/tailwind-css-component-library.mdx
+++ b/apps/www/content/blog/tailwind-css-component-library.mdx
@@ -3,7 +3,7 @@ title: "Choosing a Tailwind CSS Component Library"
description: "Discover the best Tailwind CSS component library for your project. Learn how to choose, integrate, and customize components to build stunning UIs faster."
image: https://cdn.outrank.so/9baff5d7-bb14-4bc7-8399-349ad7704876/featured-image-16b461bd-520f-4bbb-ba7a-fa11bc858a2e.jpg
author: Dillion Verma
-tag: tailwind css component library
+tag: ["Tailwind CSS", "Component Library"]
publishedOn: 2025-09-17T18:17:32.227462+00:00
featured: true
---
diff --git a/apps/www/lib/source.ts b/apps/www/lib/source.ts
index fc247c25..4cb5aa1f 100644
--- a/apps/www/lib/source.ts
+++ b/apps/www/lib/source.ts
@@ -1,17 +1,17 @@
import { blog, docs, showcase } from "@/.source";
import { loader } from "fumadocs-core/source";
-export const source: ReturnType<typeof loader> = loader({
+export const source = loader({
baseUrl: "/docs",
source: docs.toFumadocsSource(),
});
-export const blogSource: ReturnType<typeof loader> = loader({
+export const blogSource = loader({
baseUrl: "/blog",
source: blog.toFumadocsSource(),
});
-export const showcaseSource: ReturnType<typeof loader> = loader({
+export const showcaseSource = loader({
baseUrl: "/showcase",
source: showcase.toFumadocsSource(),
});
diff --git a/apps/www/lib/utils.ts b/apps/www/lib/utils.ts
index f677bda5..20246e14 100644
--- a/apps/www/lib/utils.ts
+++ b/apps/www/lib/utils.ts
@@ -7,6 +7,9 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
+export const pluralize = (count: number, word: string) =>
+ `${count} ${word}${count === 1 ? "" : "s"}`;
+
export function humanize(name: string): string {
return name
.replace(/-/g, " ")
@@ -50,6 +53,18 @@ export function formatDate(input: string | number): string {
});
}
+export const calculateReadingTime = (content: string): number => {
+ const words = content.trim().split(/\s+/).filter(Boolean).length;
+ return Math.max(1, Math.ceil(words / 200));
+};
+
+export const normalizeTag = (tag: unknown): string[] => {
+ if (!tag) return [];
+ return Array.isArray(tag)
+ ? tag.filter((t): t is string => typeof t === "string")
+ : [String(tag)];
+};
+
export function absoluteUrl(path: string) {
return `${process.env.NEXT_PUBLIC_APP_URL}${path}`;
}
diff --git a/apps/www/public/r/dot-pattern.json b/apps/www/public/r/dot-pattern.json
index a3d2ce83..6b79dc81 100644
--- a/apps/www/public/r/dot-pattern.json
+++ b/apps/www/public/r/dot-pattern.json
@@ -7,7 +7,7 @@
"files": [
{
"path": "registry/magicui/dot-pattern.tsx",
- "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion } from \"motion/react\";\nimport React, { useEffect, useId, useRef, useState } from \"react\";\n\n/**\n * DotPattern Component Props\n *\n * @param {number} [width=16] - The horizontal spacing between dots\n * @param {number} [height=16] - The vertical spacing between dots\n * @param {number} [x=0] - The x-offset of the entire pattern\n * @param {number} [y=0] - The y-offset of the entire pattern\n * @param {number} [cx=1] - The x-offset of individual dots\n * @param {number} [cy=1] - The y-offset of individual dots\n * @param {number} [cr=1] - The radius of each dot\n * @param {string} [className] - Additional CSS classes to apply to the SVG container\n * @param {boolean} [glow=false] - Whether dots should have a glowing animation effect\n */\ninterface DotPatternProps extends React.SVGProps<SVGSVGElement> {\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n cx?: number;\n cy?: number;\n cr?: number;\n className?: string;\n glow?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * DotPattern Component\n *\n * A React component that creates an animated or static dot pattern background using SVG.\n * The pattern automatically adjusts to fill its container and can optionally display glowing dots.\n *\n * @component\n *\n * @see DotPatternProps for the props interface.\n *\n * @example\n * // Basic usage\n * <DotPattern />\n *\n * // With glowing effect and custom spacing\n * <DotPattern\n * width={20}\n * height={20}\n * glow={true}\n * className=\"opacity-50\"\n * />\n *\n * @notes\n * - The component is client-side only (\"use client\")\n * - Automatically responds to container size changes\n * - When glow is enabled, dots will animate with random delays and durations\n * - Uses Motion for animations\n * - Dots color can be controlled via the text color utility classes\n */\n\nexport function DotPattern({\n width = 16,\n height = 16,\n x = 0,\n y = 0,\n cx = 1,\n cy = 1,\n cr = 1,\n className,\n glow = false,\n ...props\n}: DotPatternProps) {\n const id = useId();\n const containerRef = useRef<SVGSVGElement>(null);\n const [dimensions, setDimensions] = useState({ width: 0, height: 0 });\n\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const { width, height } = containerRef.current.getBoundingClientRect();\n setDimensions({ width, height });\n }\n };\n\n updateDimensions();\n window.addEventListener(\"resize\", updateDimensions);\n return () => window.removeEventListener(\"resize\", updateDimensions);\n }, []);\n\n const dots = Array.from(\n {\n length:\n Math.ceil(dimensions.width / width) *\n Math.ceil(dimensions.height / height),\n },\n (_, i) => {\n const col = i % Math.ceil(dimensions.width / width);\n const row = Math.floor(i / Math.ceil(dimensions.width / width));\n return {\n x: col * width + cx,\n y: row * height + cy,\n delay: Math.random() * 5,\n duration: Math.random() * 3 + 2,\n };\n },\n );\n\n return (\n <svg\n ref={containerRef}\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none absolute inset-0 h-full w-full\",\n className,\n )}\n {...props}\n >\n <defs>\n <radialGradient id={`${id}-gradient`}>\n <stop offset=\"0%\" stopColor=\"currentColor\" stopOpacity=\"1\" />\n <stop offset=\"100%\" stopColor=\"currentColor\" stopOpacity=\"0\" />\n </radialGradient>\n </defs>\n {dots.map((dot, index) => (\n <motion.circle\n key={`${dot.x}-${dot.y}`}\n cx={dot.x}\n cy={dot.y}\n r={cr}\n fill={glow ? `url(#${id}-gradient)` : \"currentColor\"}\n className=\"text-neutral-400/80\"\n initial={glow ? { opacity: 0.4, scale: 1 } : {}}\n animate={\n glow\n ? {\n opacity: [0.4, 1, 0.4],\n scale: [1, 1.5, 1],\n }\n : {}\n }\n transition={\n glow\n ? {\n duration: dot.duration,\n repeat: Infinity,\n repeatType: \"reverse\",\n delay: dot.delay,\n ease: \"easeInOut\",\n }\n : {}\n }\n />\n ))}\n </svg>\n );\n}\n",
+ "content": "\"use client\";\n\nimport { cn } from \"@/lib/utils\";\nimport { motion } from \"motion/react\";\nimport React, { useEffect, useId, useRef, useState } from \"react\";\n\n/**\n * DotPattern Component Props\n *\n * @param {number} [width=16] - The horizontal spacing between dots\n * @param {number} [height=16] - The vertical spacing between dots\n * @param {number} [x=0] - The x-offset of the entire pattern\n * @param {number} [y=0] - The y-offset of the entire pattern\n * @param {number} [cx=1] - The x-offset of individual dots\n * @param {number} [cy=1] - The y-offset of individual dots\n * @param {number} [cr=1] - The radius of each dot\n * @param {string} [className] - Additional CSS classes to apply to the SVG container\n * @param {boolean} [glow=false] - Whether dots should have a glowing animation effect\n */\ninterface DotPatternProps extends React.SVGProps<SVGSVGElement> {\n width?: number;\n height?: number;\n x?: number;\n y?: number;\n cx?: number;\n cy?: number;\n cr?: number;\n className?: string;\n glow?: boolean;\n [key: string]: unknown;\n}\n\n/**\n * DotPattern Component\n *\n * A React component that creates an animated or static dot pattern background using SVG.\n * The pattern automatically adjusts to fill its container and can optionally display glowing dots.\n *\n * @component\n *\n * @see DotPatternProps for the props interface.\n *\n * @example\n * // Basic usage\n * <DotPattern />\n *\n * // With glowing effect and custom spacing\n * <DotPattern\n * width={20}\n * height={20}\n * glow={true}\n * className=\"opacity-50\"\n * />\n *\n * @notes\n * - The component is client-side only (\"use client\")\n * - Automatically responds to container size changes\n * - When glow is enabled, dots will animate with random delays and durations\n * - Uses Motion for animations\n * - Dots color can be controlled via the text color utility classes\n */\n\nexport function DotPattern({\n width = 16,\n height = 16,\n x = 0,\n y = 0,\n cx = 1,\n cy = 1,\n cr = 1,\n className,\n glow = false,\n ...props\n}: DotPatternProps) {\n const id = useId();\n const containerRef = useRef<SVGSVGElement>(null);\n const [dimensions, setDimensions] = useState({ width: 0, height: 0 });\n\n useEffect(() => {\n const updateDimensions = () => {\n if (containerRef.current) {\n const { width, height } = containerRef.current.getBoundingClientRect();\n setDimensions({ width, height });\n }\n };\n\n updateDimensions();\n window.addEventListener(\"resize\", updateDimensions);\n return () => window.removeEventListener(\"resize\", updateDimensions);\n }, []);\n\n const dots = Array.from(\n {\n length:\n Math.ceil(dimensions.width / width) *\n Math.ceil(dimensions.height / height),\n },\n (_, i) => {\n const col = i % Math.ceil(dimensions.width / width);\n const row = Math.floor(i / Math.ceil(dimensions.width / width));\n return {\n x: col * width + cx,\n y: row * height + cy,\n delay: Math.random() * 5,\n duration: Math.random() * 3 + 2,\n };\n },\n );\n\n return (\n <svg\n ref={containerRef}\n aria-hidden=\"true\"\n className={cn(\n \"pointer-events-none absolute inset-0 h-full w-full text-neutral-400/80\",\n className,\n )}\n {...props}\n >\n <defs>\n <radialGradient id={`${id}-gradient`}>\n <stop offset=\"0%\" stopColor=\"currentColor\" stopOpacity=\"1\" />\n <stop offset=\"100%\" stopColor=\"currentColor\" stopOpacity=\"0\" />\n </radialGradient>\n </defs>\n {dots.map((dot, index) => (\n <motion.circle\n key={`${dot.x}-${dot.y}`}\n cx={dot.x}\n cy={dot.y}\n r={cr}\n fill={glow ? `url(#${id}-gradient)` : \"currentColor\"}\n initial={glow ? { opacity: 0.4, scale: 1 } : {}}\n animate={\n glow\n ? {\n opacity: [0.4, 1, 0.4],\n scale: [1, 1.5, 1],\n }\n : {}\n }\n transition={\n glow\n ? {\n duration: dot.duration,\n repeat: Infinity,\n repeatType: \"reverse\",\n delay: dot.delay,\n ease: \"easeInOut\",\n }\n : {}\n }\n />\n ))}\n </svg>\n );\n}\n",
"type": "registry:ui"
}
]
diff --git a/apps/www/source.config.ts b/apps/www/source.config.ts
index 025958e6..41e23c81 100644
--- a/apps/www/source.config.ts
+++ b/apps/www/source.config.ts
@@ -1,3 +1,5 @@
+import { transformers } from "@/lib/highlight-code";
+import { remarkImage } from "fumadocs-core/mdx-plugins";
import {
defineConfig,
defineDocs,
@@ -5,8 +7,6 @@ import {
} from "fumadocs-mdx/config";
import rehypePrettyCode from "rehype-pretty-code";
import { z } from "zod";
-import { transformers } from "@/lib/highlight-code";
-import { remarkImage } from "fumadocs-core/mdx-plugins";
export default defineConfig({
mdxOptions: {
@@ -71,7 +71,7 @@ export const blog = defineDocs({
dir: "content/blog",
docs: {
schema: frontmatterSchema.extend({
- tag: z.string().optional(),
+ tag: z.array(z.string()).optional(),
publishedOn: z.string(),
featured: z.boolean().optional().default(false),
image: z.string().optional(),
diff --git a/apps/www/tsconfig.json b/apps/www/tsconfig.json
index 9f876ac9..3251b69c 100644
--- a/apps/www/tsconfig.json
+++ b/apps/www/tsconfig.json
@@ -24,12 +24,6 @@
"@/*": ["./*"]
}
},
- "include": [
- "next-env.d.ts",
- "**/*.ts",
- "**/*.tsx",
- ".next/types/**/*.ts",
- ".content-colletions/generated"
- ],
+ "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules", "packages/**/*", "scripts/**/*"]
}