Skip to content

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

♻️ refactor: Refactor to use next13 group folders

Dillion Vermafeda6f80349f
diff --git a/app/components/[slug]/layout.tsx b/app/(docs)/components/[slug]/layout.tsx
similarity index 100%
rename from app/components/[slug]/layout.tsx
rename to app/(docs)/components/[slug]/layout.tsx
diff --git a/app/components/[slug]/page.tsx b/app/(docs)/components/[slug]/page.tsx
similarity index 99%
rename from app/components/[slug]/page.tsx
rename to app/(docs)/components/[slug]/page.tsx
index 4e91d165..ef4c7c9a 100644
--- a/app/components/[slug]/page.tsx
+++ b/app/(docs)/components/[slug]/page.tsx
@@ -1,4 +1,3 @@
-import { MDX } from "@/components/MDX";
import ComponentWrapper from "@/components/component-wrapper";
import Facebook from "@/components/icons/facebook";
import LinkedIn from "@/components/icons/linkedin";
@@ -7,6 +6,7 @@ import {
MagicBorderCard,
MagicBorderContainer,
} from "@/components/magicui/magic-border";
+import { MDX } from "@/components/mdx-components";
import { DashboardTableOfContents } from "@/components/toc";
import { ScrollArea } from "@/components/ui/scroll-area";
import { getTableOfContents } from "@/lib/toc";
diff --git a/app/components/layout.tsx b/app/(docs)/components/layout.tsx
similarity index 100%
rename from app/components/layout.tsx
rename to app/(docs)/components/layout.tsx
diff --git a/app/components/page.tsx b/app/(docs)/components/page.tsx
similarity index 97%
rename from app/components/page.tsx
rename to app/(docs)/components/page.tsx
index 878a358b..4a4eaf6a 100644
--- a/app/components/page.tsx
+++ b/app/(docs)/components/page.tsx
@@ -8,7 +8,7 @@ export const metadata = constructMetadata({
title: "Components - Magic UI",
description:
"Beautiful UI components to make your landing page look stunning.",
- image: "https://magicuikit.com/components/opengraph-image",
+ image: "https://magicuikit.com/api/og",
});
export default async function ComponentPage() {
diff --git a/app/(docs)/layout.tsx b/app/(docs)/layout.tsx
new file mode 100644
index 00000000..cbcbee55
--- /dev/null
+++ b/app/(docs)/layout.tsx
@@ -0,0 +1,16 @@
+import { SiteFooter } from "@/components/site-footer";
+import { SiteHeader } from "@/components/site-header";
+
+interface MarketingLayoutProps {
+ children: React.ReactNode;
+}
+
+export default function MarketingLayout({ children }: MarketingLayoutProps) {
+ return (
+ <div className="flex min-h-screen flex-col">
+ <SiteHeader />
+ <main className="flex-1">{children}</main>
+ <SiteFooter />
+ </div>
+ );
+}
diff --git a/app/templates/layout.tsx b/app/(docs)/templates/layout.tsx
similarity index 100%
rename from app/templates/layout.tsx
rename to app/(docs)/templates/layout.tsx
diff --git a/app/templates/page.tsx b/app/(docs)/templates/page.tsx
similarity index 98%
rename from app/templates/page.tsx
rename to app/(docs)/templates/page.tsx
index 65cbce13..e6865020 100644
--- a/app/templates/page.tsx
+++ b/app/(docs)/templates/page.tsx
@@ -6,7 +6,7 @@ import Link from "next/link";
export const metadata = constructMetadata({
title: "Templates - Magic UI",
description: "Beautiful templates to make your landing page look stunning.",
- image: "https://magicuikit.com/components/opengraph-image",
+ image: "https://magicuikit.com/api/og",
});
export default async function TemplatePage() {
diff --git a/app/(marketing)/[...slug]/page.tsx b/app/(marketing)/[...slug]/page.tsx
new file mode 100644
index 00000000..ec4bdfc3
--- /dev/null
+++ b/app/(marketing)/[...slug]/page.tsx
@@ -0,0 +1,96 @@
+import { Mdx } from "@/components/mdx-components";
+import { siteConfig } from "@/config/site";
+import { env } from "@/env.mjs";
+import { absoluteUrl } from "@/lib/utils";
+import "@/styles/mdx.css";
+import { allPages } from "contentlayer/generated";
+import { Metadata } from "next";
+import { notFound } from "next/navigation";
+
+interface PageProps {
+ params: {
+ slug: string[];
+ };
+}
+
+async function getPageFromParams(params: PageProps["params"]) {
+ const slug = params?.slug?.join("/");
+ const page = allPages.find((page) => page.slugAsParams === slug);
+
+ if (!page) {
+ null;
+ }
+
+ return page;
+}
+
+export async function generateMetadata({
+ params,
+}: PageProps): Promise<Metadata> {
+ const page = await getPageFromParams(params);
+
+ if (!page) {
+ return {};
+ }
+
+ const url = env.NEXT_PUBLIC_APP_URL;
+
+ const ogUrl = new URL(`${url}/api/og`);
+ ogUrl.searchParams.set("heading", page.title);
+ ogUrl.searchParams.set("type", siteConfig.name);
+ ogUrl.searchParams.set("mode", "light");
+
+ return {
+ title: page.title,
+ description: page.description,
+ openGraph: {
+ title: page.title,
+ description: page.description,
+ type: "article",
+ url: absoluteUrl(page.slug),
+ images: [
+ {
+ url: ogUrl.toString(),
+ width: 1200,
+ height: 630,
+ alt: page.title,
+ },
+ ],
+ },
+ twitter: {
+ card: "summary_large_image",
+ title: page.title,
+ description: page.description,
+ images: [ogUrl.toString()],
+ },
+ };
+}
+
+export async function generateStaticParams(): Promise<PageProps["params"][]> {
+ return allPages.map((page) => ({
+ slug: page.slugAsParams.split("/"),
+ }));
+}
+
+export default async function PagePage({ params }: PageProps) {
+ const page = await getPageFromParams(params);
+
+ if (!page) {
+ notFound();
+ }
+
+ return (
+ <article className="container max-w-3xl py-6 lg:py-12">
+ <div className="space-y-4">
+ <h1 className="inline-block font-heading text-4xl lg:text-5xl">
+ {page.title}
+ </h1>
+ {page.description && (
+ <p className="text-xl text-muted-foreground">{page.description}</p>
+ )}
+ </div>
+ <hr className="my-4" />
+ <Mdx code={page.body.code} />
+ </article>
+ );
+}
diff --git a/app/(marketing)/layout.tsx b/app/(marketing)/layout.tsx
new file mode 100644
index 00000000..cbcbee55
--- /dev/null
+++ b/app/(marketing)/layout.tsx
@@ -0,0 +1,16 @@
+import { SiteFooter } from "@/components/site-footer";
+import { SiteHeader } from "@/components/site-header";
+
+interface MarketingLayoutProps {
+ children: React.ReactNode;
+}
+
+export default function MarketingLayout({ children }: MarketingLayoutProps) {
+ return (
+ <div className="flex min-h-screen flex-col">
+ <SiteHeader />
+ <main className="flex-1">{children}</main>
+ <SiteFooter />
+ </div>
+ );
+}
diff --git a/app/page.tsx b/app/(marketing)/page.tsx
similarity index 59%
rename from app/page.tsx
rename to app/(marketing)/page.tsx
index 06350ef1..16ee5132 100644
--- a/app/page.tsx
+++ b/app/(marketing)/page.tsx
@@ -1,29 +1,41 @@
+import Twitter from "@/components/icons/twitter";
import { FadeIn } from "@/components/magicui/FadeIn";
import { buttonVariants } from "@/components/ui/button";
import { siteConfig } from "@/config/site";
-import { cn, constructMetadata } from "@/lib/utils";
-import { Metadata } from "next";
+import { cn } from "@/lib/utils";
import Link from "next/link";
-
-export const metadata: Metadata = constructMetadata({
- title: "Magic UI",
- description:
- "Beautiful UI components and templates to make your landing page look stunning.",
- image: "https://magicuikit.com/components/opengraph-image",
-});
+import { CSSProperties } from "react";
export default function Home() {
return (
<>
- <section className="space-y-6 pb-8 pt-6 md:pb-12 md:pt-10 lg:py-32">
+ <section className="space-y-6 pb-8 pt-20 md:pb-12 md:pt-10 lg:py-32">
<div className="container flex max-w-[64rem] flex-col items-center gap-4 text-center">
<FadeIn className="z-10 flex flex-col items-center justify-center w-full h-full">
<Link
href={siteConfig.links.twitter}
- className="rounded-2xl bg-muted px-4 py-1.5 text-sm font-medium"
+ className={cn(
+ "flex justify-center items-center flex-row",
+ "rounded-2xl px-4 py-1.5 text-sm font-medium shadow-[inset_0_-8px_10px_#8fdfff1f]",
+ "transition-shadow hover:shadow-[inset_0_-5px_10px_#8fdfff3f] ease-out duration-500",
+ "relative after:block after:w-full after:h-full after:absolute after:inset-0 after:p-[1px] after:[border-radius:inherit] after:bg-gradient-to-r after:from-[#ffaa40]/50 after:via-[#9c40ff]/50 after:to-[#ffaa40]/50 after:[mask:linear-gradient(#fff_0_0)_content-box,linear-gradient(#fff_0_0)] after:content-[''] after:[mask-composite:xor]",
+ "after:animate-gradient after:bg-[length:var(--bg-size)_100%]"
+ )}
target="_blank"
+ style={
+ {
+ "--bg-size": "300%",
+ } as CSSProperties
+ }
>
- Follow along on Twitter
+ <Twitter className="h-4 w-4 mr-2 inline-block" />
+ <div
+ className={cn(
+ `bg-clip-text text-transparent bg-gradient-to-r from-[#ffaa40] via-[#9c40ff] to-[#ffaa40] animate-gradient bg-[length:var(--bg-size)_100%]`
+ )}
+ >
+ Follow along on Twitter
+ </div>
</Link>
</FadeIn>
<FadeIn
diff --git a/app/layout.tsx b/app/layout.tsx
index 11e85055..6deefa04 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -1,11 +1,17 @@
-"use client";
-import { SiteFooter } from "@/components/site-footer";
-import { SiteHeader } from "@/components/site-header";
+import { ThemeProvider } from "@/components/theme-provider";
+import { Toaster } from "@/components/ui/toaster";
import { fontSans } from "@/lib/fonts";
-import { cn } from "@/lib/utils";
-import { ThemeProvider } from "next-themes";
-import "./globals.css";
-import "./mdx.css";
+import { cn, constructMetadata } from "@/lib/utils";
+import "@/styles/globals.css";
+import "@/styles/mdx.css";
+import { Metadata } from "next";
+
+export const metadata: Metadata = constructMetadata({
+ title: "Magic UI",
+ description:
+ "Beautiful UI components and templates to make your landing page look stunning.",
+ image: "https://magicuikit.com/api/og",
+});
export default function RootLayout({
children,
@@ -22,16 +28,11 @@ export default function RootLayout({
)}
>
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
- <div className="relative flex min-h-screen flex-col">
- <SiteHeader />
- <div className="flex-1">{children}</div>
- <SiteFooter />
- </div>
+ {children}
+ <Toaster />
+ {/* <Analytics /> */}
{/* <TailwindIndicator /> */}
</ThemeProvider>
- {/* <Analytics /> */}
- {/* <NewYorkToaster />
- <DefaultToaster /> */}
</body>
</html>
);
diff --git a/app/globals.css b/styles/globals.css
similarity index 100%
rename from app/globals.css
rename to styles/globals.css
diff --git a/app/mdx.css b/styles/mdx.css
similarity index 100%
rename from app/mdx.css
rename to styles/mdx.css