UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.
🐛 fix: more refactors
Dillion Verma0eeebcc91e38
diff --git a/components/mdx-components.tsx b/components/mdx-components.tsxnew file mode 100644index 00000000..e6e9e80f--- /dev/null+++ b/components/mdx-components.tsx@@ -0,0 +1,119 @@+"use client";++import { cn } from "@/lib/utils";+import { useMDXComponent } from "next-contentlayer/hooks";+import Image from "next/image";+import Link from "next/link";+import { ComponentSource } from "./component-source";+import { CopyButton } from "./copy-button";++const CustomLink = (props: any) => {+ const href = props.href;++ if (href.startsWith("/")) {+ return (+ <Link {...props} href={href}>+ {props.children}+ </Link>+ );+ }++ if (href.startsWith("#")) {+ return <a {...props} />;+ }++ return <a target="_blank" rel="noopener noreferrer" {...props} />;+};++const components = {+ a: CustomLink,+ Image,+ ComponentSource,+ Step: ({ className, ...props }: React.ComponentProps<"h3">) => (+ <h4+ className={cn(+ "font-heading mt-8 scroll-m-20 text-xl font-semibold tracking-tight",+ className+ )}+ {...props}+ />+ ),+ Steps: ({ ...props }) => (+ <div+ className="[&>h4]:step mb-12 ml-4 border-l pl-8 [counter-reset:step]"+ {...props}+ />+ ),+ pre: ({+ className,+ __rawString__,+ // __npmCommand__,+ // __pnpmCommand__,+ // __yarnCommand__,+ __withMeta__,+ __src__,+ // __event__,+ // __style__,+ ...props+ }: React.HTMLAttributes<HTMLPreElement> & {+ // __style__?: Style["name"]+ __rawString__?: string;+ __withMeta__?: boolean;+ __src__?: string;+ // __event__?: Event["name"]+ }) => {+ return (+ <>+ <pre+ className={cn(+ "mb-4 mt-6 max-h-[650px] overflow-x-auto rounded-lg border bg-zinc-950 py-4 dark:bg-zinc-900",+ className+ )}+ {...props}+ />+ {__rawString__ && (+ <CopyButton+ value={__rawString__}+ src={__src__}+ // event={__event__}+ className={cn("absolute right-4 top-4", __withMeta__ && "top-16")}+ />+ )}+ {/* {__npmCommand__ && __yarnCommand__ && __pnpmCommand__ && (+ <CopyNpmCommandButton+ commands={{+ __npmCommand__,+ __pnpmCommand__,+ __yarnCommand__,+ }}+ className={cn("absolute right-4 top-4", __withMeta__ && "top-16")}+ />+ )} */}+ </>+ );+ },+};++interface MDXProps {+ code: string;+}++export function Mdx({ code }: MDXProps) {+ const Component = useMDXComponent(code);++ return (+ <article+ className={cn(+ `prose dark:prose-invert prose-gray leading-tighter tracking-tighter`,+ // `md:prose-lg lg:prose-xl`,+ `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:py-4 prose-pre:dark:bg-gray-900 prose-pre:px-0 prose-pre:text-sm prose-pre:tracking-tighter`+ )}+ >+ {/* @ts-ignore */}+ <Component components={components} />+ </article>+ );+}diff --git a/components/theme-provider.tsx b/components/theme-provider.tsxnew file mode 100644index 00000000..f0584299--- /dev/null+++ b/components/theme-provider.tsx@@ -0,0 +1,8 @@+"use client";++import { ThemeProvider as NextThemesProvider } from "next-themes";+import { ThemeProviderProps } from "next-themes/dist/types";++export function ThemeProvider({ children, ...props }: ThemeProviderProps) {+ return <NextThemesProvider {...props}>{children}</NextThemesProvider>;+}diff --git a/content/pages/privacy.mdx b/content/pages/privacy.mdxnew file mode 100644index 00000000..9a6e32e3--- /dev/null+++ b/content/pages/privacy.mdx@@ -0,0 +1,4 @@+---+title: Privacy+description: The Privacy Policy for Magic UI+---diff --git a/content/pages/terms.mdx b/content/pages/terms.mdxnew file mode 100644index 00000000..1aa145f1--- /dev/null+++ b/content/pages/terms.mdx@@ -0,0 +1,4 @@+---+title: Terms & Conditions+description: Read our terms and conditions+---diff --git a/contentlayer.config.ts b/contentlayer.config.tsindex 756c008b..a24993fe 100644--- a/contentlayer.config.ts+++ b/contentlayer.config.ts@@ -8,6 +8,46 @@ import { BlogPosting, WithContext } from "schema-dts";import { visit } from "unist-util-visit";import { env } from "./env.mjs";+/** @type {import('contentlayer/source-files').ComputedFields} */+const computedFields = {+ url: {+ type: "string",+ resolve: (post: any) => `/${post._raw.flattenedPath}`,+ },+ image: {+ type: "string",+ resolve: (post: any) =>+ `${env.NEXT_PUBLIC_APP_URL}/api/og?title=${encodeURI(post.title)}`,+ },+ slug: {+ type: "string",+ resolve: (doc: any) => `/${doc._raw.flattenedPath}`,+ },+ slugAsParams: {+ type: "string",+ resolve: (doc: any) => doc._raw.flattenedPath.split("/").slice(1).join("/"),+ },+ structuredData: {+ type: "json",+ resolve: (doc: any) =>+ ({+ "@context": "https://schema.org",+ "@type": `BlogPosting`,+ headline: doc.title,+ datePublished: doc.date,+ dateModified: doc.date,+ description: doc.summary,+ image: doc.image,+ url: `https://magicuikit.com/${doc._raw.flattenedPath}`,+ author: {+ "@type": "Person",+ name: doc.author,+ url: `https://twitter.com/${doc.author}`,+ },+ } as WithContext<BlogPosting>),+ },+};+export const Component = defineDocumentType(() => ({name: "Component",filePathPattern: `components/**/*.mdx`,@@ -21,45 +61,30 @@ export const Component = defineDocumentType(() => ({published: { type: "boolean", required: false, default: true },toc: { type: "boolean", default: true, required: false },},- computedFields: {- url: {- type: "string",- resolve: (post) => `/${post._raw.flattenedPath}`,- },- image: {+ // @ts-ignore+ computedFields,+}));++export const Page = defineDocumentType(() => ({+ name: "Page",+ filePathPattern: `pages/**/*.mdx`,+ contentType: "mdx",+ fields: {+ title: {type: "string",- resolve: (post) =>- `${env.NEXT_PUBLIC_APP_URL}/api/og?title=${encodeURI(post.title)}`,+ required: true,},- slug: {+ description: {type: "string",- resolve: (post) => post._raw.flattenedPath.replace(`components/`, ""),- },- structuredData: {- type: "json",- resolve: (doc) =>- ({- "@context": "https://schema.org",- "@type": `BlogPosting`,- headline: doc.title,- datePublished: doc.date,- dateModified: doc.date,- description: doc.summary,- image: doc.image,- url: `https://magicuikit.com/${doc._raw.flattenedPath}`,- author: {- "@type": "Person",- name: doc.author,- url: `https://twitter.com/${doc.author}`,- },- } as WithContext<BlogPosting>),},},+ // @ts-ignore+ computedFields,}));export default makeSource({contentDirPath: "./content",- documentTypes: [Component],+ documentTypes: [Component, Page],mdx: {remarkPlugins: [remarkGfm],rehypePlugins: [