Skip to content

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

feat: add refactored docs (#8)

Dillion Verma82a89a253fdb
diff --git a/app/(docs)/blocks/layout.tsx b/app/(docs)/blocks/layout.tsx
deleted file mode 100644
index 7bfb0ea8..00000000
--- a/app/(docs)/blocks/layout.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-interface BlocksLayoutProps {
- children: React.ReactNode;
-}
-
-export default function BlocksLayout({ children }: BlocksLayoutProps) {
- return (
- <div className="border-b">
- <div className="container flex-1 items-start">
- {/* <aside className="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block">
- <ScrollArea className="h-full py-6 pl-8 pr-6 lg:py-8">
- <DocsSidebarNav items={docsConfig.sidebarNav} />
- </ScrollArea>
- </aside> */}
- {children}
- </div>
- </div>
- );
-}
diff --git a/app/(docs)/blocks/page.tsx b/app/(docs)/blocks/page.tsx
deleted file mode 100644
index b24a336d..00000000
--- a/app/(docs)/blocks/page.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import { allComponents } from "@/.contentlayer/generated";
-import { constructMetadata } from "@/lib/utils";
-import FadeIn from "@/registry/components/magicui/fade-in";
-import { compareDesc } from "date-fns";
-import { Link } from "lucide-react";
-
-export const metadata = constructMetadata({
- title: "Blocks | Magic UI",
- description: "Beautiful building blocks for your next project.",
-});
-
-export default async function BlocksPage() {
- const posts = allComponents
- .filter((post) => post.date <= new Date().toISOString() && post.published)
- .sort((a, b) => {
- return compareDesc(new Date(a.date), new Date(b.date));
- });
-
- return (
- <div className="container max-w-4xl py-6 lg:py-10">
- <div className="flex flex-col items-start gap-4 md:flex-row md:justify-between md:gap-8">
- <div className="flex-1 space-y-4">
- <h1 className="font-heading inline-block text-4xl tracking-tight lg:text-5xl">
- Blocks
- </h1>
- <p className="text-xl text-muted-foreground">
- A collection of ready to use building blocks for your next project.
- </p>
- </div>
- </div>
- <hr className="my-8" />
- {posts?.length ? (
- <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
- {posts.map((post, index) => (
- <FadeIn key={post._id} delay={index * 0.04}>
- <article
- key={post._id}
- className="group relative flex h-full w-full grow flex-col overflow-hidden rounded-xl border bg-background transition-all duration-300 hover:border-gray-300 dark:border-gray-800 dark:hover:border-gray-700"
- >
- {post.video && (
- <div className="overflow-hidden">
- <video
- src={post.video}
- autoPlay
- loop
- muted
- playsInline
- className="pointer-events-none relative -bottom-1 aspect-video" // needed because random black line at bottom of video
- />
- </div>
- )}
- <div className="flex flex-1 flex-col justify-end p-3">
- <h2>{post.title}</h2>
- {/* {post.date && (
- <p className="text-sm text-gray-500">
- {formatDate(post.date)}
- </p>
- )} */}
- {post.summary && (
- <p className="mb-2 text-base text-muted-foreground">
- {post.summary}
- </p>
- )}
- </div>
-
- <Link href={post.url} className="absolute inset-0">
- <span className="sr-only">View Article</span>
- </Link>
- </article>
- </FadeIn>
- ))}
- </div>
- ) : (
- <p>No components yet.</p>
- )}
- </div>
- );
-}
diff --git a/app/(docs)/components/[slug]/layout.tsx b/app/(docs)/components/[slug]/layout.tsx
deleted file mode 100644
index 97f6187a..00000000
--- a/app/(docs)/components/[slug]/layout.tsx
+++ /dev/null
@@ -1,26 +0,0 @@
-import { DocsSidebarNav } from "@/components/sidebar-nav";
-import { ScrollArea } from "@/components/ui/scroll-area";
-import { docsConfig } from "@/config/docs";
-import { cn } from "@/lib/utils";
-
-interface DocsLayoutProps {
- children: React.ReactNode;
-}
-
-export default function DocsLayout({ children }: DocsLayoutProps) {
- return (
- <div
- className={cn(
- "flex-1 items-start md:grid md:gap-6 lg:gap-10",
- "md:grid-cols-[220px_minmax(0,1fr)] lg:grid-cols-[240px_minmax(0,1fr)]",
- )}
- >
- <aside className="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block">
- <ScrollArea className="h-full py-6 pl-8 pr-6 lg:py-8">
- <DocsSidebarNav items={docsConfig.sidebarNav} />
- </ScrollArea>
- </aside>
- {children}
- </div>
- );
-}
diff --git a/app/(docs)/components/[slug]/not-found.tsx b/app/(docs)/components/[slug]/not-found.tsx
deleted file mode 100644
index 59ae1fab..00000000
--- a/app/(docs)/components/[slug]/not-found.tsx
+++ /dev/null
@@ -1,5 +0,0 @@
-import PreOrder from "@/components/preorder";
-
-export default async function NotFound() {
- return <PreOrder />;
-}
diff --git a/app/(docs)/components/[slug]/page.tsx b/app/(docs)/components/[slug]/page.tsx
deleted file mode 100644
index 076d17f2..00000000
--- a/app/(docs)/components/[slug]/page.tsx
+++ /dev/null
@@ -1,174 +0,0 @@
-import Facebook from "@/components/icons/facebook";
-import LinkedIn from "@/components/icons/linkedin";
-import Twitter from "@/components/icons/twitter";
-import { Mdx } from "@/components/mdx-components";
-import { ComponentPager } from "@/components/pager";
-import { DashboardTableOfContents } from "@/components/toc";
-import { ScrollArea } from "@/components/ui/scroll-area";
-import { getTableOfContents } from "@/lib/toc";
-import { absoluteUrl, cn, constructMetadata } from "@/lib/utils";
-import { allComponents } from "contentlayer/generated";
-import { ChevronRight } from "lucide-react";
-import type { Metadata } from "next";
-import Link from "next/link";
-import { notFound } from "next/navigation";
-import Balancer from "react-wrap-balancer";
-
-// TODO: Fix this in future
-// https://nextjs.org/docs/app/api-reference/file-conventions/route-segment-config#dynamicparams
-
-export async function generateStaticParams() {
- return allComponents.map((component) => ({
- slug: component.slugAsParams,
- }));
-}
-
-export async function generateMetadata({
- params,
-}: {
- params: { slug: string };
-}): Promise<Metadata | undefined> {
- const component = allComponents.find(
- (component) => component.slugAsParams === params.slug,
- );
- if (!component) {
- return;
- }
-
- const {
- title,
- date: publishedTime,
- summary: description,
- image,
- slug,
- } = component;
-
- return constructMetadata({
- title: `${title} | Magic UI`,
- description,
- image,
- openGraph: {
- title: `${title} | Magic UI`,
- description,
- type: "article",
- publishedTime,
- tags: [
- "React",
- "Tailwind CSS",
- "Framer Motion",
- "Landing Page",
- "Components",
- "Next.js",
- ],
- url: absoluteUrl(slug),
- images: [
- {
- url: image,
- width: 1200,
- height: 630,
- alt: "Magic UI",
- },
- ],
- },
- });
-}
-
-interface Props {
- params: { slug: string };
-}
-
-export default async function Component({ params }: Props) {
- const component = allComponents.find(
- (component) => component.slugAsParams === params.slug,
- );
- if (!component) {
- notFound();
- }
-
- const toc = await getTableOfContents(component.body.raw);
-
- return (
- <main
- className={cn("relative py-6 lg:gap-10 lg:py-8 xl:grid ", {
- "xl:grid-cols-[1fr_300px]": component.toc,
- })}
- >
- <div className="mx-auto w-full">
- {/* Breadcrumb */}
- <div className="mb-4 flex items-center space-x-1 text-sm text-muted-foreground">
- <Link
- href="/components"
- className="transition-colors hover:text-foreground/80"
- >
- <div className="overflow-hidden text-ellipsis whitespace-nowrap">
- Components
- </div>
- </Link>
- <ChevronRight className="h-4 w-4" />
- <div className="font-medium text-foreground">{component.title}</div>
- </div>
-
- {/* Title */}
- <div className="space-y-2">
- <h1 className={cn("scroll-m-20 text-4xl font-bold tracking-tight")}>
- {component.title}
- </h1>
- {component.summary && (
- <p className="text-lg text-muted-foreground">
- <Balancer>{component.summary}</Balancer>
- </p>
- )}
- </div>
-
- <div className="mt-4 flex items-center justify-between">
- <div className="flex items-center space-x-6">
- <Link
- href={`https://twitter.com/intent/tweet?text=${component.title}&url=magicui.design/components/${component.slugAsParams}&via=${component.author}`}
- target="_blank"
- rel="noopener noreferrer"
- >
- <Twitter className="h-6 w-6" />
- </Link>
- <Link
- href={`
- http://www.linkedin.com/shareArticle?mini=true&url=https://magicui.design/components/${component.slugAsParams}`}
- target="_blank"
- rel="noopener noreferrer"
- >
- <LinkedIn className="h-6 w-6" />
- </Link>
- <Link
- href={`https://www.facebook.com/sharer/sharer.php?u=https://magicui.design/components/${component.slugAsParams}`}
- target="_blank"
- rel="noopener noreferrer"
- >
- <Facebook className="h-6 w-6" />
- </Link>
- </div>
- </div>
-
- <div className="pb-12 pt-8">
- <Mdx code={component.body.code} />
- </div>
- <ComponentPager doc={component} />
- </div>
-
- {component.toc && (
- <div className="hidden text-sm xl:block">
- <div className="sticky top-16 -mt-10 h-[calc(100vh-3.5rem)] overflow-hidden pt-6">
- <ScrollArea className="pb-10">
- <DashboardTableOfContents toc={toc} />
- </ScrollArea>
- </div>
- </div>
- )}
-
- <script
- type="application/ld+json"
- dangerouslySetInnerHTML={{
- __html: JSON.stringify(component.structuredData),
- }}
- />
- </main>
- );
-}
diff --git a/app/(docs)/components/layout.tsx b/app/(docs)/components/layout.tsx
deleted file mode 100644
index a60891cb..00000000
--- a/app/(docs)/components/layout.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-interface ComponentLayoutProps {
- children: React.ReactNode;
-}
-
-export default function ComponentLayout({ children }: ComponentLayoutProps) {
- return (
- <div className="container flex-1 items-start">
- {/* <aside className="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block">
- <ScrollArea className="h-full py-6 pl-8 pr-6 lg:py-8">
- <DocsSidebarNav items={docsConfig.sidebarNav} />
- </ScrollArea>
- </aside> */}
- {children}
- </div>
- );
-}
diff --git a/app/(docs)/components/page.tsx b/app/(docs)/components/page.tsx
deleted file mode 100644
index f5f1f6b4..00000000
--- a/app/(docs)/components/page.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import { constructMetadata } from "@/lib/utils";
-import FadeIn from "@/registry/components/magicui/fade-in";
-import { allComponents } from "contentlayer/generated";
-import { compareDesc } from "date-fns";
-import Link from "next/link";
-
-export async function generateStaticParams() {
- return allComponents.map((component) => ({
- slug: component.slugAsParams,
- }));
-}
-
-export const metadata = constructMetadata({
- title: "Components | Magic UI",
- description:
- "Beautiful UI components to make your landing page look stunning.",
-});
-
-export default async function ComponentPage() {
- const posts = allComponents
- .filter((post) => post.date <= new Date().toISOString() && post.published)
- .sort((a, b) => {
- return compareDesc(new Date(a.date), new Date(b.date));
- });
-
- return (
- <div className="container max-w-screen-lg py-6 lg:py-10">
- <div className="flex flex-col items-start gap-4 md:flex-row md:justify-between md:gap-8">
- <div className="flex-1 space-y-4">
- <h1 className="inline-block text-4xl font-medium tracking-tighter lg:text-5xl">
- Components
- </h1>
- <p className="text-xl text-muted-foreground">
- A collection of components that can be used in your own projects.
- </p>
- </div>
- </div>
- <hr className="my-8" />
- {posts?.length ? (
- <div className="grid grid-cols-1 gap-4 md:grid-cols-2">
- {posts.map((post, index) => (
- <FadeIn key={post._id} delay={0.2}>
- <article
- key={post._id}
- className="group relative flex h-full w-full grow flex-col overflow-hidden rounded-xl border bg-background transition-all duration-300 hover:border-gray-300 dark:border-gray-800 dark:hover:border-gray-700"
- >
- {post.video && (
- <div className="overflow-hidden">
- <video
- src={post.video}
- autoPlay
- loop
- muted
- playsInline
- className="pointer-events-none relative -bottom-1 aspect-video" // needed because random black line at bottom of video
- />
- </div>
- )}
- <div className="flex flex-1 flex-col justify-end p-3">
- <h2>{post.title}</h2>
- {/* {post.date && (
- <p className="text-sm text-gray-500">
- {formatDate(post.date)}
- </p>
- )} */}
- {post.summary && (
- <p className="mb-2 text-base text-muted-foreground">
- {post.summary}
- </p>
- )}
- </div>
-
- <Link href={post.url} className="absolute inset-0">
- <span className="sr-only">View Article</span>
- </Link>
- </article>
- </FadeIn>
- ))}
- </div>
- ) : (
- <p>No components yet.</p>
- )}
- </div>
- );
-}
diff --git a/app/(docs)/docs/[[...slug]]/page.tsx b/app/(docs)/docs/[[...slug]]/page.tsx
new file mode 100644
index 00000000..a7aa7c1e
--- /dev/null
+++ b/app/(docs)/docs/[[...slug]]/page.tsx
@@ -0,0 +1,162 @@
+import { Mdx } from "@/components/mdx-components";
+import { DocPager } from "@/components/pager";
+import { DashboardTableOfContents } from "@/components/toc";
+import { badgeVariants } from "@/components/ui/badge";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { siteConfig } from "@/config/site";
+import { getTableOfContents } from "@/lib/toc";
+import { absoluteUrl, cn } from "@/lib/utils";
+import "@/styles/mdx.css";
+import { ChevronRightIcon, ExternalLinkIcon } from "@radix-ui/react-icons";
+import { allDocs } from "contentlayer/generated";
+import type { Metadata } from "next";
+import Link from "next/link";
+import { notFound } from "next/navigation";
+import Balancer from "react-wrap-balancer";
+
+interface DocPageProps {
+ params: {
+ slug: string[];
+ };
+}
+
+async function getDocFromParams({ params }: DocPageProps) {
+ const slug = params.slug?.join("/") || "";
+ const doc = allDocs.find((doc) => doc.slugAsParams === slug);
+
+ if (!doc) {
+ return null;
+ }
+
+ return doc;
+}
+
+export async function generateMetadata({
+ params,
+}: DocPageProps): Promise<Metadata> {
+ const doc = await getDocFromParams({ params });
+
+ if (!doc) {
+ return {};
+ }
+
+ return {
+ title: doc.title,
+ description: doc.description,
+ openGraph: {
+ title: doc.title,
+ description: doc.description,
+ type: "article",
+ url: absoluteUrl(doc.slug),
+ images: [
+ {
+ url: siteConfig.ogImage,
+ width: 1200,
+ height: 630,
+ alt: siteConfig.name,
+ },
+ ],
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: doc.title,
+ description: doc.description,
+ images: [siteConfig.ogImage],
+ creator: "@shadcn",
+ },
+ };
+}
+
+export async function generateStaticParams(): Promise<
+ DocPageProps["params"][]
+> {
+ return allDocs.map((doc) => ({
+ slug: doc.slugAsParams.split("/"),
+ }));
+}
+
+export default async function DocPage({ params }: DocPageProps) {
+ const doc = await getDocFromParams({ params });
+
+ if (!doc || !doc.published) {
+ notFound();
+ }
+
+ const toc = await getTableOfContents(doc.body.raw);
+
+ return (
+ <main
+ className={cn("relative py-6 lg:gap-10 lg:py-8 xl:grid ", {
+ "xl:grid-cols-[1fr_300px]": doc.toc,
+ })}
+ >
+ <div className="mx-auto w-full min-w-0">
+ <div className="mb-4 flex items-center space-x-1 text-sm text-muted-foreground">
+ <div className="overflow-hidden text-ellipsis whitespace-nowrap">
+ Docs
+ </div>
+ <ChevronRightIcon className="h-4 w-4" />
+ <div className="font-medium text-foreground">{doc.title}</div>
+ </div>
+ <div className="space-y-2">
+ <h1 className={cn("scroll-m-20 text-4xl font-bold tracking-tight")}>
+ {doc.title}
+ </h1>
+ {doc.description && (
+ <p className="text-lg text-muted-foreground">
+ <Balancer>{doc.description}</Balancer>
+ </p>
+ )}
+ </div>
+ {doc.links ? (
+ <div className="flex items-center space-x-2 pt-4">
+ {doc.links?.doc && (
+ <Link
+ href={doc.links.doc}
+ target="_blank"
+ rel="noreferrer"
+ className={cn(badgeVariants({ variant: "secondary" }), "gap-1")}
+ >
+ Docs
+ <ExternalLinkIcon className="h-3 w-3" />
+ </Link>
+ )}
+ {doc.links?.api && (
+ <Link
+ href={doc.links.api}
+ target="_blank"
+ rel="noreferrer"
+ className={cn(badgeVariants({ variant: "secondary" }), "gap-1")}
+ >
+ API Reference
+ <ExternalLinkIcon className="h-3 w-3" />
+ </Link>
+ )}
+ </div>
+ ) : null}
+ <div className="pb-12 pt-8">
+ <Mdx code={doc.body.code} />
+ </div>
+ <DocPager doc={doc} />
+ </div>
+ {doc.toc && (
+ <div className="hidden text-sm xl:block">
+ <div className="sticky top-16 -mt-10 pt-4">
+ <ScrollArea className="pb-10">
+ <div className="sticky top-16 -mt-10 h-[calc(100vh-3.5rem)] py-12">
+ <DashboardTableOfContents toc={toc} />
+ </div>
+ </ScrollArea>
+ </div>
+ </div>
+ )}
+
+ <script
+ type="application/ld+json"
+ dangerouslySetInnerHTML={{
+ __html: JSON.stringify(doc.structuredData),
+ }}
+ />
+ </main>
+ );
+}
diff --git a/app/(docs)/docs/layout.tsx b/app/(docs)/docs/layout.tsx
new file mode 100644
index 00000000..ea5d019d
--- /dev/null
+++ b/app/(docs)/docs/layout.tsx
@@ -0,0 +1,22 @@
+import { DocsSidebarNav } from "@/components/sidebar-nav";
+import { ScrollArea } from "@/components/ui/scroll-area";
+import { docsConfig } from "@/config/docs";
+
+interface DocsLayoutProps {
+ children: React.ReactNode;
+}
+
+export default function DocsLayout({ children }: DocsLayoutProps) {
+ return (
+ <div className="border-b">
+ <div className="container flex-1 items-start md:grid md:grid-cols-[220px_minmax(0,1fr)] md:gap-6 lg:grid-cols-[240px_minmax(0,1fr)] lg:gap-10">
+ <aside className="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block">
+ <ScrollArea className="h-full py-6 pr-6 lg:py-8">
+ <DocsSidebarNav items={docsConfig.sidebarNav} />
+ </ScrollArea>
+ </aside>
+ {children}
+ </div>
+ </div>
+ );
+}
diff --git a/app/(docs)/docs/not-found.tsx b/app/(docs)/docs/not-found.tsx
new file mode 100644
index 00000000..61a66312
--- /dev/null
+++ b/app/(docs)/docs/not-found.tsx
@@ -0,0 +1,41 @@
+"use client";
+
+import { Icons } from "@/components/icons";
+import { Button, buttonVariants } from "@/components/ui/button";
+import Link from "next/link";
+import { useRouter } from "next/navigation";
+
+export default function NotFound() {
+ const router = useRouter();
+ return (
+ <section>
+ <div className="container mx-auto flex min-h-[calc(100vh-8rem)] items-center px-6 py-12">
+ <div className="mx-auto flex max-w-sm flex-col items-center text-center">
+ <p className="rounded-full bg-blue-50 p-3 text-sm font-medium dark:bg-gray-800">
+ <Icons.warning className="h-6 w-6" />
+ </p>
+ <h1 className="mt-3 text-2xl font-semibold text-gray-800 dark:text-white md:text-3xl">
+ Page not found
+ </h1>
+ <p className="mt-4 text-gray-500 dark:text-gray-400">
+ The page you are looking for doesn&apos;t exist.
+ </p>
+
+ <div className="group mt-6 flex w-full shrink-0 items-center gap-x-3 sm:w-auto">
+ <Button
+ onClick={() => router.back()}
+ className={buttonVariants({ variant: "secondary" })}
+ >
+ <Icons.chevronLeft className="h-4 w-4 transition-transform group-hover:-translate-x-1" />
+ <span>Go back</span>
+ </Button>
+
+ <Link href="/" className={buttonVariants({ variant: "default" })}>
+ Take me home
+ </Link>
+ </div>
+ </div>
+ </div>
+ </section>
+ );
+}
diff --git a/app/(docs)/templates/layout.tsx b/app/(docs)/templates/layout.tsx
deleted file mode 100644
index c7c1fed4..00000000
--- a/app/(docs)/templates/layout.tsx
+++ /dev/null
@@ -1,18 +0,0 @@
-interface TemplateLayoutProps {
- children: React.ReactNode;
-}
-
-export default function TemplateLayout({ children }: TemplateLayoutProps) {
- return (
- <div className="border-b">
- <div className="container flex-1 items-start">
- {/* <aside className="fixed top-14 z-30 -ml-2 hidden h-[calc(100vh-3.5rem)] w-full shrink-0 md:sticky md:block">
- <ScrollArea className="h-full py-6 pl-8 pr-6 lg:py-8">
- <DocsSidebarNav items={docsConfig.sidebarNav} />
- </ScrollArea>
- </aside> */}
- {children}
- </div>
- </div>
- );
-}
diff --git a/app/(docs)/templates/page.tsx b/app/(docs)/templates/page.tsx
deleted file mode 100644
index 60591d49..00000000
--- a/app/(docs)/templates/page.tsx
+++ /dev/null
@@ -1,27 +0,0 @@
-import { Component } from "@/.contentlayer/generated";
-import { constructMetadata } from "@/lib/utils";
-
-export const metadata = constructMetadata({
- title: "Templates | Magic UI",
- description: "Beautiful templates to make your landing page look stunning.",
-});
-
-export default async function TemplatePage() {
- const posts: Component[] = [];
-
- return (
- <div className="container max-w-4xl py-6 lg:py-10">
- <div className="flex flex-col items-start gap-4 md:flex-row md:justify-between md:gap-8">
- <div className="flex-1 space-y-4">
- <h1 className="font-heading inline-block text-4xl tracking-tight lg:text-5xl">
- Templates
- </h1>
- <p className="text-xl text-muted-foreground">
- A collection of templates that can be used in your own projects.
- </p>
- </div>
- </div>
- <hr className="my-8" />
- </div>
- );
-}
diff --git a/app/sitemap.ts b/app/sitemap.ts
index f5898d5b..d96a63b2 100644
--- a/app/sitemap.ts
+++ b/app/sitemap.ts
@@ -1,4 +1,4 @@
-import { allComponents, allPages } from "@/.contentlayer/generated";
+import { allDocs, allPages } from "@/.contentlayer/generated";
import { MetadataRoute } from "next";
import { headers } from "next/headers";
@@ -20,8 +20,8 @@ export default function sitemap(): MetadataRoute.Sitemap {
url: `${protocol}://${domain}/${post.slugAsParams}`,
lastModified: new Date(),
})),
- ...allComponents.map((post) => ({
- url: `${protocol}://${domain}/components/${post.slugAsParams}`,
+ ...allDocs.map((post) => ({
+ url: `${protocol}://${domain}/docs/${post.slugAsParams}`,
lastModified: post.date,
})),
];
diff --git a/components/landing/hero.tsx b/components/landing/hero.tsx
index 20945278..e3bcc063 100644
--- a/components/landing/hero.tsx
+++ b/components/landing/hero.tsx
@@ -1,4 +1,4 @@
-import { allComponents } from "@/.contentlayer/generated";
+import { allDocs } from "@/.contentlayer/generated";
import { buttonVariants } from "@/components/ui/button";
import { Separator } from "@/components/ui/separator";
import { db } from "@/lib/db";
@@ -18,10 +18,16 @@ export default async function Hero() {
},
});
- const post = allComponents
- .filter((post) => post.date <= new Date().toISOString() && post.published)
+ const post = allDocs
+ .filter(
+ (post) =>
+ post.date && post.date <= new Date().toISOString() && post.published,
+ )
.sort((a, b) => {
- return compareDesc(new Date(a.date), new Date(b.date));
+ if (!a.date && !b.date) return 0; // Both dates are undefined, keep original order
+ if (!a.date) return 1; // Move a to the end if date is undefined
+ if (!b.date) return -1; // Move b to the end if date is undefined
+ return compareDesc(new Date(a.date), new Date(b.date)); // Both dates are defined, proceed with comparison
})[0];
return (
@@ -59,9 +65,7 @@ export default async function Hero() {
<ChevronRight className="ml-1 h-4 w-4 text-gray-500" />
</Link>
</FadeIn>
- <FadeIn
- // delay={0.0}
- >
+ <FadeIn>
<h1 className="text-5xl font-bold tracking-tighter sm:text-6xl md:text-7xl lg:text-8xl">
Create Magical <br /> Landing Pages <br />
</h1>
diff --git a/components/mdx-components.tsx b/components/mdx-components.tsx
index 22bb5fc0..b13954f8 100644
--- a/components/mdx-components.tsx
+++ b/components/mdx-components.tsx
@@ -1,5 +1,12 @@
+import {
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+} from "@/components/ui/accordion";
import { Event } from "@/lib/events";
import { cn } from "@/lib/utils";
+import TweetCard from "@/registry/components/magicui/tweet-card";
import { useMDXComponent } from "next-contentlayer/hooks";
import Image from "next/image";
import Link from "next/link";
@@ -26,10 +33,43 @@ const CustomLink = (props: any) => {
};
const components = {
- a: CustomLink,
+ Accordion,
+ AccordionContent,
+ AccordionItem,
+ AccordionTrigger,
+ a: (props: any) => (
+ <CustomLink
+ {...props}
+ className={"font-medium underline underline-offset-4"}
+ />
+ ),
Image,
+ Tweet: ({ id }: { id: string }) => (
+ <TweetCard id={id} className="not-prose mx-auto" />
+ ),
ComponentPreview,
ComponentSource: (props: any) => <ComponentSource {...props} />,
+ p: ({ className, ...props }: React.HTMLAttributes<HTMLParagraphElement>) => (
+ <p
+ className={cn("leading-7 [&:not(:first-child)]:mt-6", className)}
+ {...props}
+ />
+ ),
+ ul: ({ className, ...props }: React.HTMLAttributes<HTMLUListElement>) => (
+ <ul className={cn("my-6 ml-6 list-disc", className)} {...props} />
+ ),
+ ol: ({ className, ...props }: React.HTMLAttributes<HTMLOListElement>) => (
+ <ol className={cn("my-6 ml-6 list-decimal", className)} {...props} />
+ ),
+ li: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
+ <li className={cn("mt-2", className)} {...props} />
+ ),
+ blockquote: ({ className, ...props }: React.HTMLAttributes<HTMLElement>) => (
+ <blockquote
+ className={cn("mt-6 border-l-2 pl-6 italic", className)}
+ {...props}
+ />
+ ),
table: ({ className, ...props }: React.HTMLAttributes<HTMLTableElement>) => (
<div className="w-full overflow-y-auto">
<table className={cn("w-full", className)} {...props} />
@@ -138,11 +178,12 @@ export function Mdx({ code }: MDXProps) {
// `md:prose-lg lg:prose-xl`,
// no underline on links
- `prose-a:no-underline`,
+ // `prose-a:no-underline`,
// `prose-a:transition-colors prose-a:duration-200 prose-a:ease-out`,
// `dark:prose-a:text-gray-200 prose-a:underline-offset-4 dark:hover:prose-a:text-gray-700 prose-a:font-semibold hover:prose-a:text-gray-400`,
// `prose-pre:bg-gray-900 prose-pre:rounded-xl prose-pre:overflow-x-auto prose-pre:border prose-pre:px-0 `,
- `prose-pre:mb-4 prose-pre:mt-6 prose-pre:max-h-[650px] prose-pre:overflow-x-auto prose-pre:rounded-lg prose-pre:border prose-pre:bg-gray-900 prose-pre:px-0 prose-pre:py-4 prose-pre:text-xs prose-pre:tracking-tighter prose-pre:dark:bg-gray-900 md:prose-pre:text-sm`,
+
+ `prose-pre:mb-4 prose-pre:mt-6 prose-pre:max-h-[650px] prose-pre:overflow-x-auto prose-pre:rounded-lg prose-pre:border prose-pre:px-0 prose-pre:py-4 prose-pre:text-xs prose-pre:tracking-tighter md:prose-pre:text-sm`,
)}
>
{/* @ts-ignore */}
diff --git a/components/pager.tsx b/components/pager.tsx
index 111d3983..95cc29c7 100644
--- a/components/pager.tsx
+++ b/components/pager.tsx
@@ -1,16 +1,16 @@
+import { Doc } from "@/.contentlayer/generated";
import { buttonVariants } from "@/components/ui/button";
import { docsConfig } from "@/config/docs";
import { cn } from "@/lib/utils";
import { NavItem, NavItemWithChildren } from "@/types";
import { ChevronLeftIcon, ChevronRightIcon } from "@radix-ui/react-icons";
-import { Component } from "contentlayer/generated";
import Link from "next/link";
interface DocsPagerProps {
- doc: Component;
+ doc: Doc;
}
-export function ComponentPager({ doc }: DocsPagerProps) {
+export function DocPager({ doc }: DocsPagerProps) {
const pager = getPagerForDoc(doc);
if (!pager) {
@@ -41,7 +41,7 @@ export function ComponentPager({ doc }: DocsPagerProps) {
);
}
-export function getPagerForDoc(doc: Component) {
+export function getPagerForDoc(doc: Doc) {
const flattenedLinks = [null, ...flatten(docsConfig.sidebarNav), null];
const activeIndex = flattenedLinks.findIndex(
(link) => doc.slug === link?.href,
diff --git a/components/site-header.tsx b/components/site-header.tsx
index 4b0a42d3..d1eb98a3 100644
--- a/components/site-header.tsx
+++ b/components/site-header.tsx
@@ -8,6 +8,7 @@ import { UserAccountNav } from "@/components/user-account-nav";
import { siteConfig } from "@/config/site";
import { env } from "@/env.mjs";
import { cn } from "@/lib/utils";
+import { DiscordLogoIcon } from "@radix-ui/react-icons";
import { User } from "next-auth";
import Link from "next/link";
@@ -31,23 +32,17 @@ export function SiteHeader({ user }: SiteHeaderProps) {
<CommandMenu />
</div>
<nav className="flex items-center gap-2">
- {/* <Link
- href={siteConfig.links.twitter}
- target="_blank"
- rel="noreferrer"
- >
+ <Link href="/discord" target="_blank" rel="noreferrer">
<div
className={cn(
- buttonVariants({
- variant: "ghost",
- }),
- "w-9 px-0"
+ buttonVariants({ variant: "ghost" }),
+ "hover-[#5865F2] w-9 gap-2 px-0 text-[#5865F2]",
)}
>
- <Icons.gitHub className="h-4 w-4" />
- <span className="sr-only">Twitter</span>
+ <DiscordLogoIcon className="h-4 w-4 fill-current" />
+ <span className="sr-only">Discord</span>
</div>
- </Link> */}
+ </Link>
<Link
href={siteConfig.links.twitter}
target="_blank"
diff --git a/config/docs.ts b/config/docs.ts
index af57df16..b1ccb2e9 100644
--- a/config/docs.ts
+++ b/config/docs.ts
@@ -1,4 +1,4 @@
-import { allComponents } from "@/.contentlayer/generated";
+import { allDocs } from "@/.contentlayer/generated";
import { MainNavItem, SidebarNavItem } from "@/types";
import { compareDesc } from "date-fns";
@@ -29,18 +29,49 @@ export const docsConfig: DocsConfig = {
},
],
sidebarNav: [
+ {
+ title: "Getting Started",
+ items: [
+ {
+ title: "Introduction",
+ href: "/docs",
+ items: [],
+ },
+ // {
+ // title: "Installation",
+ // href: "/docs/installation",
+ // items: [],
+ // },
+ // {
+ // title: "Changelog",
+ // href: "/docs/changelog",
+ // items: [],
+ // },
+ // {
+ // title: "Story",
+ // href: "/docs/story",
+ // items: [],
+ // },
+ ],
+ },
{
title: "Components",
- items: allComponents
+ items: allDocs
.filter(
- (post) => post.date <= new Date().toISOString() && post.published,
+ (post) =>
+ post.date &&
+ post.date <= new Date().toISOString() &&
+ post.published,
)
.sort((a, b) => {
- return compareDesc(new Date(a.date), new Date(b.date));
+ if (!a.date && !b.date) return 0; // Both dates are undefined, keep original order
+ if (!a.date) return 1; // Move a to the end if date is undefined
+ if (!b.date) return -1; // Move b to the end if date is undefined
+ return compareDesc(new Date(a.date), new Date(b.date)); // Both dates are defined, proceed with comparison
})
.map((component) => ({
title: component.title,
- href: `/components/${component.slugAsParams}`,
+ href: `/docs/${component.slugAsParams}`,
items: [],
})),
},
diff --git a/config/site.ts b/config/site.ts
index 567aba22..e3fd94e8 100644
--- a/config/site.ts
+++ b/config/site.ts
@@ -6,6 +6,7 @@ export const siteConfig = {
"Beautifully designed landing page components built with React & Tailwind CSS.",
links: {
twitter: "https://twitter.com/dillionverma",
+ discord: "https://discord.gg/WfefJAwQhF",
},
keywords: [
"React",
diff --git a/content/docs/changelog.mdx b/content/docs/changelog.mdx
new file mode 100644
index 00000000..2ecf97fc
--- /dev/null
+++ b/content/docs/changelog.mdx
@@ -0,0 +1,4 @@
+---
+title: Changelog
+description: A history of changes for Magic UI
+---
diff --git a/content/components/animated-beam.mdx b/content/docs/components/animated-beam.mdx
similarity index 96%
rename from content/components/animated-beam.mdx
rename to content/docs/components/animated-beam.mdx
index dc598a56..c4684cca 100644
--- a/content/components/animated-beam.mdx
+++ b/content/docs/components/animated-beam.mdx
@@ -1,7 +1,7 @@
---
title: Animated Beam
date: 2024-02-11
-summary: An animated beam of light which travels along a path. Useful for showcasing the "integration" features of a website.
+description: An animated beam of light which travels along a path. Useful for showcasing the "integration" features of a website.
author: dillionverma
published: true
video: https://cdn.magicui.design/animated-beam.mp4
diff --git a/content/components/animated-grid-pattern.mdx b/content/docs/components/animated-grid-pattern.mdx
similarity index 94%
rename from content/components/animated-grid-pattern.mdx
rename to content/docs/components/animated-grid-pattern.mdx
index e543bb00..67da637d 100644
--- a/content/components/animated-grid-pattern.mdx
+++ b/content/docs/components/animated-grid-pattern.mdx
@@ -1,7 +1,7 @@
---
title: Animated Grid Pattern
date: 2024-02-07
-summary: A animated background grid pattern made with SVGs, fully customizable using Tailwind CSS.
+description: A animated background grid pattern made with SVGs, fully customizable using Tailwind CSS.
author: dillionverma
published: false
video: https://cdn.magicui.design/grid-pattern.mp4
diff --git a/content/components/animated-lines.mdx b/content/docs/components/animated-lines.mdx
similarity index 87%
rename from content/components/animated-lines.mdx
rename to content/docs/components/animated-lines.mdx
index 0aa5c67a..445f5fdd 100644
--- a/content/components/animated-lines.mdx
+++ b/content/docs/components/animated-lines.mdx
@@ -1,7 +1,7 @@
---
title: Animated Lines
date: 2023-12-19
-summary: A list that animates each item in sequence with a delay. Used to showcase notifications or events on your landing page.
+description: A list that animates each item in sequence with a delay. Used to showcase notifications or events on your landing page.
author: dillionverma
published: false
video: https://cdn.magicui.design/animated-lines.mp4
diff --git a/content/components/animated-list.mdx b/content/docs/components/animated-list.mdx
similarity index 88%
rename from content/components/animated-list.mdx
rename to content/docs/components/animated-list.mdx
index e2e77b17..93624fa8 100644
--- a/content/components/animated-list.mdx
+++ b/content/docs/components/animated-list.mdx
@@ -1,7 +1,7 @@
---
title: Animated List
date: 2023-12-12
-summary: A list that animates each item in sequence with a delay. Used to showcase notifications or events on your landing page.
+description: A list that animates each item in sequence with a delay. Used to showcase notifications or events on your landing page.
author: dillionverma
published: true
video: https://cdn.magicui.design/animated-list.mp4
diff --git a/content/components/bento-grid.mdx b/content/docs/components/bento-grid.mdx
similarity index 89%
rename from content/components/bento-grid.mdx
rename to content/docs/components/bento-grid.mdx
index 9c59d1f6..1c4f8818 100644
--- a/content/components/bento-grid.mdx
+++ b/content/docs/components/bento-grid.mdx
@@ -1,7 +1,7 @@
---
title: Bento Grid
date: 2023-11-09
-summary: Bento grid is a layout used to showcase the features of a product in a simple and elegant way.
+description: Bento grid is a layout used to showcase the features of a product in a simple and elegant way.
author: dillionverma
published: true
toc: false
diff --git a/content/components/border-beam.mdx b/content/docs/components/border-beam.mdx
similarity index 96%
rename from content/components/border-beam.mdx
rename to content/docs/components/border-beam.mdx
index 2f3ff38c..40dece33 100644
--- a/content/components/border-beam.mdx
+++ b/content/docs/components/border-beam.mdx
@@ -1,7 +1,7 @@
---
title: Border Beam
date: 2024-02-06
-summary: An animated beam of light which travels along the border of its container.
+description: An animated beam of light which travels along the border of its container.
author: dillionverma
published: true
video: https://cdn.magicui.design/border-beam.mp4
diff --git a/content/components/dot-pattern.mdx b/content/docs/components/dot-pattern.mdx
similarity index 94%
rename from content/components/dot-pattern.mdx
rename to content/docs/components/dot-pattern.mdx
index fe0dad6f..e10c615b 100644
--- a/content/components/dot-pattern.mdx
+++ b/content/docs/components/dot-pattern.mdx
@@ -1,7 +1,7 @@
---
title: Dot Pattern
date: 2023-07-20
-summary: A background dot pattern made with SVGs, fully customizable using Tailwind CSS.
+description: A background dot pattern made with SVGs, fully customizable using Tailwind CSS.
author: dillionverma
published: true
video: https://cdn.magicui.design/dot-pattern.mp4
diff --git a/content/components/globe.mdx b/content/docs/components/globe.mdx
similarity index 93%
rename from content/components/globe.mdx
rename to content/docs/components/globe.mdx
index a6100037..459e9570 100644
--- a/content/components/globe.mdx
+++ b/content/docs/components/globe.mdx
@@ -1,7 +1,7 @@
---
title: Globe
date: 2023-08-02
-summary: An autorotating, interactive, and highly performant globe made using WebGL.
+description: An autorotating, interactive, and highly performant globe made using WebGL.
author: dillionverma
published: true
video: https://cdn.magicui.design/globe.mp4
diff --git a/content/components/grid-pattern.mdx b/content/docs/components/grid-pattern.mdx
similarity index 94%
rename from content/components/grid-pattern.mdx
rename to content/docs/components/grid-pattern.mdx
index e1acb61e..1ecc008c 100644
--- a/content/components/grid-pattern.mdx
+++ b/content/docs/components/grid-pattern.mdx
@@ -1,7 +1,7 @@
---
title: Grid Pattern
date: 2023-07-18
-summary: A background grid pattern made with SVGs, fully customizable using Tailwind CSS.
+description: A background grid pattern made with SVGs, fully customizable using Tailwind CSS.
author: dillionverma
published: true
video: https://cdn.magicui.design/grid-pattern.mp4
diff --git a/content/components/hero-video.mdx b/content/docs/components/hero-video.mdx
similarity index 91%
rename from content/components/hero-video.mdx
rename to content/docs/components/hero-video.mdx
index e7cf8bdc..8e7e8c76 100644
--- a/content/components/hero-video.mdx
+++ b/content/docs/components/hero-video.mdx
@@ -1,7 +1,7 @@
---
title: Hero Video
date: 2023-08-30
-summary: A react component that renders a video in a modal with a play button.
+description: A react component that renders a video in a modal with a play button.
author: dillionverma
published: false
toc: true
diff --git a/content/components/linear-gradient.mdx b/content/docs/components/linear-gradient.mdx
similarity index 95%
rename from content/components/linear-gradient.mdx
rename to content/docs/components/linear-gradient.mdx
index 9860390d..107e3d3f 100644
--- a/content/components/linear-gradient.mdx
+++ b/content/docs/components/linear-gradient.mdx
@@ -1,7 +1,7 @@
---
title: Linear Gradient
date: 2023-07-12
-summary: A linear gradient that can be used as a background for a component.
+description: A linear gradient that can be used as a background for a component.
author: dillionverma
published: true
video: https://cdn.magicui.design/linear-gradient.mp4
diff --git a/content/components/magic-card.mdx b/content/docs/components/magic-card.mdx
similarity index 95%
rename from content/components/magic-card.mdx
rename to content/docs/components/magic-card.mdx
index f7417231..ffeb7cc2 100644
--- a/content/components/magic-card.mdx
+++ b/content/docs/components/magic-card.mdx
@@ -1,7 +1,7 @@
---
title: Magic Card
date: 2023-07-02
-summary: A spotlight effect that follows your mouse cursor and highlights borders on hover.
+description: A spotlight effect that follows your mouse cursor and highlights borders on hover.
author: dillionverma
published: true
video: https://cdn.magicui.design/magic-card.mp4
diff --git a/content/components/marquee.mdx b/content/docs/components/marquee.mdx
similarity index 96%
rename from content/components/marquee.mdx
rename to content/docs/components/marquee.mdx
index eef4a1f3..4336716c 100644
--- a/content/components/marquee.mdx
+++ b/content/docs/components/marquee.mdx
@@ -1,7 +1,7 @@
---
title: Marquee
date: 2023-07-26
-summary: An infinite scrolling component that can be used to display text, images, or videos.
+description: An infinite scrolling component that can be used to display text, images, or videos.
author: dillionverma
published: true
video: https://cdn.magicui.design/marquee.mp4
diff --git a/content/components/meteors.mdx b/content/docs/components/meteors.mdx
similarity index 96%
rename from content/components/meteors.mdx
rename to content/docs/components/meteors.mdx
index 7736b1d7..b361d7f2 100644
--- a/content/components/meteors.mdx
+++ b/content/docs/components/meteors.mdx
@@ -1,7 +1,7 @@
---
title: Meteors
date: 2023-07-13
-summary: A meteor shower effect.
+description: A meteor shower effect.
author: dillionverma
published: true
video: https://cdn.magicui.design/meteors.mp4
diff --git a/content/components/number-ticker.mdx b/content/docs/components/number-ticker.mdx
similarity index 91%
rename from content/components/number-ticker.mdx
rename to content/docs/components/number-ticker.mdx
index e09535e7..eb0ef566 100644
--- a/content/components/number-ticker.mdx
+++ b/content/docs/components/number-ticker.mdx
@@ -1,7 +1,7 @@
---
title: Number Ticker
date: 2023-11-18
-summary: Animate numbers to count up or down to a target number
+description: Animate numbers to count up or down to a target number
author: dillionverma
published: true
video: https://cdn.magicui.design/number-ticker.mp4
diff --git a/content/components/particles.mdx b/content/docs/components/particles.mdx
similarity index 89%
rename from content/components/particles.mdx
rename to content/docs/components/particles.mdx
index d6ef9f26..7af567ee 100644
--- a/content/components/particles.mdx
+++ b/content/docs/components/particles.mdx
@@ -1,7 +1,7 @@
---
title: Particles
date: 2024-02-01
-summary: Particles are a fun way to add some visual flair to your website. They can be used to create a sense of depth, movement, and interactivity.
+description: Particles are a fun way to add some visual flair to your website. They can be used to create a sense of depth, movement, and interactivity.
author: dillionverma
published: false
video: https://cdn.magicui.design/particles.mp4
diff --git a/content/components/radial-gradient.mdx b/content/docs/components/radial-gradient.mdx
similarity index 92%
rename from content/components/radial-gradient.mdx
rename to content/docs/components/radial-gradient.mdx
index 0e19556e..b61964ff 100644
--- a/content/components/radial-gradient.mdx
+++ b/content/docs/components/radial-gradient.mdx
@@ -1,7 +1,7 @@
---
title: Radial Gradient
date: 2023-07-12
-summary: A circular gradient that can be used as a background for a component.
+description: A circular gradient that can be used as a background for a component.
author: dillionverma
published: true
video: https://cdn.magicui.design/radial-gradient.mp4
diff --git a/content/components/retro-grid.mdx b/content/docs/components/retro-grid.mdx
similarity index 95%
rename from content/components/retro-grid.mdx
rename to content/docs/components/retro-grid.mdx
index ba3cce5c..32ae2175 100644
--- a/content/components/retro-grid.mdx
+++ b/content/docs/components/retro-grid.mdx
@@ -1,7 +1,7 @@
---
title: Retro Grid
date: 2023-11-23
-summary: An animated scrolling retro grid effect
+description: An animated scrolling retro grid effect
author: dillionverma
published: true
video: https://cdn.magicui.design/retro-grid.mp4
diff --git a/content/components/ripple.mdx b/content/docs/components/ripple.mdx
similarity index 90%
rename from content/components/ripple.mdx
rename to content/docs/components/ripple.mdx
index 33401d24..56a734d7 100644
--- a/content/components/ripple.mdx
+++ b/content/docs/components/ripple.mdx
@@ -1,7 +1,7 @@
---
title: Ripple
date: 2023-11-18
-summary: An animated ripple effect typically used behind elements to emphasize them.
+description: An animated ripple effect typically used behind elements to emphasize them.
author: dillionverma
published: true
video: https://cdn.magicui.design/ripple.mp4
diff --git a/content/components/shimmer-button.mdx b/content/docs/components/shimmer-button.mdx
similarity index 96%
rename from content/components/shimmer-button.mdx
rename to content/docs/components/shimmer-button.mdx
index a17bc1de..2ea8a7a5 100644
--- a/content/components/shimmer-button.mdx
+++ b/content/docs/components/shimmer-button.mdx
@@ -1,7 +1,7 @@
---
title: Shimmer Button
date: 2023-08-10
-summary: A button with a shimmering light which travels around the perimeter.
+description: A button with a shimmering light which travels around the perimeter.
author: dillionverma
published: true
video: https://cdn.magicui.design/shimmer-button.mp4
diff --git a/content/components/temp.mdx b/content/docs/components/temp.mdx
similarity index 100%
rename from content/components/temp.mdx
rename to content/docs/components/temp.mdx
diff --git a/content/components/text-shimmer.mdx b/content/docs/components/text-shimmer.mdx
similarity index 93%
rename from content/components/text-shimmer.mdx
rename to content/docs/components/text-shimmer.mdx
index 2b2ae7b9..52dee8ea 100644
--- a/content/components/text-shimmer.mdx
+++ b/content/docs/components/text-shimmer.mdx
@@ -1,7 +1,7 @@
---
title: Text Shimmer
date: 2024-01-16
-summary: A light glare effect which pans across text making it appear as if it is shimmering.
+description: A light glare effect which pans across text making it appear as if it is shimmering.
author: dillionverma
published: true
video: https://cdn.magicui.design/text-shimmer.mp4
diff --git a/content/components/tweet-card.mdx b/content/docs/components/tweet-card.mdx
similarity index 95%
rename from content/components/tweet-card.mdx
rename to content/docs/components/tweet-card.mdx
index 88dc95d5..3d2f6e08 100644
--- a/content/components/tweet-card.mdx
+++ b/content/docs/components/tweet-card.mdx
@@ -1,7 +1,7 @@
---
title: Tweet Card
date: 2023-10-15
-summary: A card that displays a tweet with the author's name, handle, and profile picture.
+description: A card that displays a tweet with the author's name, handle, and profile picture.
author: dillionverma
published: true
video: https://cdn.magicui.design/tweet-card.mp4
diff --git a/content/docs/index.mdx b/content/docs/index.mdx
new file mode 100644
index 00000000..b99c2515
--- /dev/null
+++ b/content/docs/index.mdx
@@ -0,0 +1,26 @@
+---
+title: Introduction
+description: Create magical landing pages with components that you can copy and paste into your apps.
+---
+
+
+Magic UI is a collection of re-usable components that you can copy and paste into your web apps.
+
+It primarily features components, blocks, and templates geared towards creating landing pages and user-facing marketing materials.
+
+__I personally believe that good design contributes significant value to software. It's one of the main methods of establishing trust between you and an internet stranger__. Trust is important for internet businesses because it is the first thing a visitor evaluates before pulling out their credit card and becoming a customer.
+
+Some questions visitors might ask themselves are:
+- "Is this company legit?"
+- "Who else is using it?"
+- "Can I trust them with my personal data?"
+
+__Poor design reflects poorly on your team.__ It comes off as lazy, unfinished, and unstable. It shows that the team doesn't care about user experience.
+
+__Good design tells me that the team behind has their shit together.__ I can probably expect good things from them in the future.
+
+It makes users think "if they care so much about these tiny details, they must care a lot about other things in the company, including their customers!".
+
+A great example of this in play is https://linear.app landing page which I first came across in 2020. I didn't even need to try the product but I already knew that it *must* be good.
+
+This library is heavily inspired by [https://ui.shadcn.com](https://ui.shadcn.com).
\ No newline at end of file
diff --git a/content/docs/installation.mdx b/content/docs/installation.mdx
new file mode 100644
index 00000000..0a7d2c92
--- /dev/null
+++ b/content/docs/installation.mdx
@@ -0,0 +1,153 @@
+---
+title: Installation
+description: Install and configure Next.js.
+published: false
+---
+
+<Steps>
+
+### Create project
+
+Start by creating a new Next.js project using `create-next-app`:
+
+```bash
+npx create-next-app@latest my-app --typescript --tailwind --eslint
+```
+
+### Run the CLI
+
+Run the `shadcn-ui` init command to setup your project:
+
+```bash
+npx shadcn-ui@latest init
+```
+
+### Configure components.json
+
+You will be asked a few questions to configure `components.json`:
+
+```txt showLineNumbers
+Would you like to use TypeScript (recommended)? no / yes
+Which style would you like to use? › Default
+Which color would you like to use as base color? › Slate
+Where is your global CSS file? › › app/globals.css
+Do you want to use CSS variables for colors? › no / yes
+Are you using a custom tailwind prefix eg. tw-? (Leave blank if not) ...
+Where is your tailwind.config.js located? › tailwind.config.js
+Configure the import alias for components: › @/components
+Configure the import alias for utils: › @/lib/utils
+Are you using React Server Components? › no / yes
+```
+
+### Fonts
+
+I use [Inter](https://rsms.me/inter/) as the default font. Inter is not required. You can replace it with any other font.
+
+Here's how I configure Inter for Next.js:
+
+**1. Import the font in the root layout:**
+
+```js showLineNumbers title=app/layout.tsx {2,5-8,16-17}
+import "@/styles/globals.css"
+import { Inter as FontSans } from "next/font/google"
+
+import { cn } from "../@/lib/utils"
+
+const fontSans = FontSans({
+ subsets: ["latin"],
+ variable: "--font-sans",
+})
+
+export default function RootLayout({ children }: RootLayoutProps) {
+ return (
+ <html lang="en" suppressHydrationWarning>
+ <head />
+ <body
+ className={cn(
+ "min-h-screen bg-background font-sans antialiased",
+ fontSans.variable
+ )}
+ >
+ ...
+ </body>
+ </html>
+ )
+}
+```
+
+**2. Configure `theme.extend.fontFamily` in `tailwind.config.js`**
+
+```js showLineNumbers title=tailwind.config.js {9-11}
+const { fontFamily } = require("tailwindcss/defaultTheme")
+
+/** @type {import('tailwindcss').Config} */
+module.exports = {
+ darkMode: ["class"],
+ content: ["app/**/*.{ts,tsx}", "components/**/*.{ts,tsx}"],
+ theme: {
+ extend: {
+ fontFamily: {
+ sans: ["var(--font-sans)", ...fontFamily.sans],
+ },
+ },
+ },
+}
+```
+
+### App structure
+
+Here's how I structure my Next.js apps. You can use this as a reference:
+
+```txt {6-10,14-15}
+.
+├── app
+│ ├── layout.tsx
+│ └── page.tsx
+├── components
+│ ├── ui
+│ │ ├── alert-dialog.tsx
+│ │ ├── button.tsx
+│ │ ├── dropdown-menu.tsx
+│ │ └── ...
+│ ├── main-nav.tsx
+│ ├── page-header.tsx
+│ └── ...
+├── lib
+│ └── utils.ts
+├── styles
+│ └── globals.css
+├── next.config.js
+├── package.json
+├── postcss.config.js
+├── tailwind.config.js
+└── tsconfig.json
+```
+
+- I place the UI components in the `components/ui` folder.
+- The rest of the components such as `<PageHeader />` and `<MainNav />` are placed in the `components` folder.
+- The `lib` folder contains all the utility functions. I have a `utils.ts` where I define the `cn` helper.
+- The `styles` folder contains the global CSS.
+
+### That's it
+
+You can now start adding components to your project.
+
+```bash
+npx shadcn-ui@latest add button
+```
+
+The command above will add the `Button` component to your project. You can then import it like this:
+
+```tsx {1,6} showLineNumbers
+import { Button } from "@/components/ui/button"
+
+export default function Home() {
+ return (
+ <div>
+ <Button>Click me</Button>
+ </div>
+ )
+}
+```
+
+</Steps>
\ No newline at end of file
diff --git a/content/docs/story.mdx b/content/docs/story.mdx
new file mode 100644
index 00000000..b3befe60
--- /dev/null
+++ b/content/docs/story.mdx
@@ -0,0 +1,34 @@
+---
+title: Story
+description: Learn about how Magic UI started
+published: false
+---
+
+Magic UI started because of an annoying problem I faced in the summer of 2023.
+
+I developed my [first SaaS app](https://automatic.chat) a few months earlier and was trying to redesign the landing page for it. However, none of the code I wrote matched my expectations in my head for how it would turn out. I was irritated by the process and I especially didn't like having to deal with responsiveness, and animations in particular. Both were really time consuming for me and I felt like I wasn't making progress on actually delivering value to my SaaS users.
+
+I was trying to make landing pages like https://linear.app, https://wope.com and https://reflect.app but they were instead turning out like websites designed in 1995.
+
+**I tried to search the web for good tutorials, code examples, or guides on how to make a landing page like https://linear.app but I found nothing.**
+
+That same week I tweeted that I would just build it myself.
+
+<Tweet id="1668408059125702661" />
+
+This tweet immediately went viral and it seemed like there were others like me who resonated!
+
+I started building the foundations of this site as well as a few components and within 10 days, Magic UI was in the hands of users.
+
+People seem to love it and we're just getting started.
+
+<div className="columns-3 [&>*]:mb-4 gap-4">
+ <Tweet id="1722659583464968612" />
+ <Tweet id="1668442365625790465" />
+ <Tweet id="1684613797984800768" />
+ <Tweet id="1722690049374830639" />
+ <Tweet id="1684676668445622272" />
+ <Tweet id="1668640878225764354" />
+ <Tweet id="1668506160620769280" />
+ <Tweet id="1681477151042797568" />
+</div>
diff --git a/contentlayer.config.ts b/contentlayer.config.ts
index 80a9122b..d938e63e 100644
--- a/contentlayer.config.ts
+++ b/contentlayer.config.ts
@@ -1,5 +1,9 @@
// contentlayer.config.ts
-import { defineDocumentType, makeSource } from "contentlayer/source-files";
+import {
+ defineDocumentType,
+ defineNestedType,
+ makeSource,
+} from "contentlayer/source-files";
import rehypeAutolinkHeadings from "rehype-autolink-headings";
import rehypePrettyCode from "rehype-pretty-code";
import rehypeSlug from "rehype-slug";
@@ -49,27 +53,38 @@ const computedFields = {
},
};
-export const Component = defineDocumentType(() => ({
- name: "Component",
- filePathPattern: `components/**/*.mdx`,
+export const Page = defineDocumentType(() => ({
+ name: "Page",
+ filePathPattern: `pages/**/*.mdx`,
contentType: "mdx",
fields: {
- title: { type: "string", required: true },
- type: { type: "string", required: false },
- date: { type: "date", required: true },
- video: { type: "string", required: false },
- summary: { type: "string", required: true },
- author: { type: "string", required: true },
- published: { type: "boolean", required: false, default: true },
- toc: { type: "boolean", default: false, required: false },
+ title: {
+ type: "string",
+ required: true,
+ },
+ description: {
+ type: "string",
+ },
},
// @ts-ignore
computedFields,
}));
-export const Page = defineDocumentType(() => ({
- name: "Page",
- filePathPattern: `pages/**/*.mdx`,
+const LinksProperties = defineNestedType(() => ({
+ name: "LinksProperties",
+ fields: {
+ doc: {
+ type: "string",
+ },
+ api: {
+ type: "string",
+ },
+ },
+}));
+
+export const Doc = defineDocumentType(() => ({
+ name: "Doc",
+ filePathPattern: `docs/**/*.mdx`,
contentType: "mdx",
fields: {
title: {
@@ -78,7 +93,30 @@ export const Page = defineDocumentType(() => ({
},
description: {
type: "string",
+ required: true,
+ },
+ date: { type: "date", required: false },
+ published: {
+ type: "boolean",
+ default: true,
+ },
+ links: {
+ type: "nested",
+ of: LinksProperties,
+ },
+ featured: {
+ type: "boolean",
+ default: false,
+ required: false,
},
+ component: {
+ type: "boolean",
+ default: false,
+ required: false,
+ },
+ toc: { type: "boolean", default: false, required: false },
+ author: { type: "string", required: false },
+ video: { type: "string", required: false },
},
// @ts-ignore
computedFields,
@@ -86,7 +124,7 @@ export const Page = defineDocumentType(() => ({
export default makeSource({
contentDirPath: "./content",
- documentTypes: [Component, Page],
+ documentTypes: [Page, Doc],
mdx: {
remarkPlugins: [remarkGfm],
rehypePlugins: [
diff --git a/next.config.js b/next.config.js
index c533cf17..c5d827f2 100644
--- a/next.config.js
+++ b/next.config.js
@@ -16,6 +16,25 @@ const nextConfig = {
images: {
domains: ["localhost", "cdn.magicui.design"],
},
+ async redirects() {
+ return [
+ {
+ source: "/components",
+ destination: "/docs/components/animated-beam",
+ permanent: true,
+ },
+ {
+ source: "/components/:path*",
+ destination: "/docs/components/:path*",
+ permanent: true,
+ },
+ {
+ source: "/docs/components",
+ destination: "/docs/components/animated-beam",
+ permanent: true,
+ },
+ ];
+ },
};
module.exports = withContentlayer(nextConfig);