diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..55a12ae --- /dev/null +++ b/.gitignore @@ -0,0 +1,28 @@ +# deps +/node_modules + +# generated content +.contentlayer +.content-collections +.source + +# test & build +/coverage +/.next/ +/out/ +/build +*.tsbuildinfo + +# misc +.DS_Store +*.pem +/.pnp +.pnp.js +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# others +.env*.local +.vercel +next-env.d.ts \ No newline at end of file diff --git a/app/(home)/layout.tsx b/app/(home)/layout.tsx new file mode 100644 index 0000000..bcf8cba --- /dev/null +++ b/app/(home)/layout.tsx @@ -0,0 +1,7 @@ +import type { ReactNode } from "react" +import { HomeLayout } from "fumadocs-ui/home-layout" +import { baseOptions } from "../layout.config" + +export default function Layout({ children }: { children: ReactNode }): React.ReactElement { + return {children} +} diff --git a/app/(home)/page.tsx b/app/(home)/page.tsx new file mode 100644 index 0000000..115965e --- /dev/null +++ b/app/(home)/page.tsx @@ -0,0 +1,16 @@ +import Link from "next/link" + +export default function HomePage() { + return ( +
+

Hello World

+

+ You can open{" "} + + /docs + {" "} + and see the documentation. +

+
+ ) +} diff --git a/app/api/search/route.ts b/app/api/search/route.ts new file mode 100644 index 0000000..076ff6c --- /dev/null +++ b/app/api/search/route.ts @@ -0,0 +1,12 @@ +import { source } from "@/app/source" +import { createSearchAPI } from "fumadocs-core/search/server" + +export const { GET } = createSearchAPI("advanced", { + indexes: source.getPages().map(page => ({ + title: page.data.title, + description: page.data.description, + structuredData: page.data.structuredData, + id: page.url, + url: page.url + })) +}) diff --git a/app/docs/[[...slug]]/page.tsx b/app/docs/[[...slug]]/page.tsx new file mode 100644 index 0000000..fd8b4c1 --- /dev/null +++ b/app/docs/[[...slug]]/page.tsx @@ -0,0 +1,36 @@ +import { source } from "@/app/source" +import type { Metadata } from "next" +import { DocsPage, DocsBody, DocsDescription, DocsTitle } from "fumadocs-ui/page" +import { notFound } from "next/navigation" +import defaultMdxComponents from "fumadocs-ui/mdx" + +export default async function Page({ params }: { params: { slug?: string[] } }) { + const page = source.getPage(params.slug) + if (!page) notFound() + + const MDX = page.data.body + + return ( + + {page.data.title} + {page.data.description} + + + + + ) +} + +export async function generateStaticParams() { + return source.generateParams() +} + +export function generateMetadata({ params }: { params: { slug?: string[] } }) { + const page = source.getPage(params.slug) + if (!page) notFound() + + return { + title: page.data.title, + description: page.data.description + } satisfies Metadata +} diff --git a/app/docs/layout.tsx b/app/docs/layout.tsx new file mode 100644 index 0000000..53aeec2 --- /dev/null +++ b/app/docs/layout.tsx @@ -0,0 +1,12 @@ +import { DocsLayout } from "fumadocs-ui/layout" +import type { ReactNode } from "react" +import { baseOptions } from "../layout.config" +import { source } from "@/app/source" + +export default function Layout({ children }: { children: ReactNode }) { + return ( + + {children} + + ) +} diff --git a/app/global.css b/app/global.css new file mode 100644 index 0000000..b5c61c9 --- /dev/null +++ b/app/global.css @@ -0,0 +1,3 @@ +@tailwind base; +@tailwind components; +@tailwind utilities; diff --git a/app/layout.config.tsx b/app/layout.config.tsx new file mode 100644 index 0000000..de1c757 --- /dev/null +++ b/app/layout.config.tsx @@ -0,0 +1,21 @@ +import { type HomeLayoutProps } from "fumadocs-ui/home-layout" + +/** + * Shared layout configurations + * + * you can configure layouts individually from: + * Home Layout: app/(home)/layout.tsx + * Docs Layout: app/docs/layout.tsx + */ +export const baseOptions: HomeLayoutProps = { + nav: { + title: "My App" + }, + links: [ + { + text: "Documentation", + url: "/docs", + active: "nested-url" + } + ] +} diff --git a/app/layout.tsx b/app/layout.tsx new file mode 100644 index 0000000..0b62794 --- /dev/null +++ b/app/layout.tsx @@ -0,0 +1,18 @@ +import "./global.css" +import { RootProvider } from "fumadocs-ui/provider" +import { Inter } from "next/font/google" +import type { ReactNode } from "react" + +const inter = Inter({ + subsets: ["latin"] +}) + +export default function Layout({ children }: { children: ReactNode }) { + return ( + + + {children} + + + ) +} diff --git a/app/source.ts b/app/source.ts new file mode 100644 index 0000000..72899df --- /dev/null +++ b/app/source.ts @@ -0,0 +1,8 @@ +import { docs, meta } from "@/.source" +import { createMDXSource } from "fumadocs-mdx" +import { loader } from "fumadocs-core/source" + +export const source = loader({ + baseUrl: "/docs", + source: createMDXSource(docs, meta) +}) diff --git a/bun.lockb b/bun.lockb new file mode 100755 index 0000000..9768e23 Binary files /dev/null and b/bun.lockb differ diff --git a/content/docs/index.mdx b/content/docs/index.mdx new file mode 100644 index 0000000..986a7fa --- /dev/null +++ b/content/docs/index.mdx @@ -0,0 +1,13 @@ +--- +title: Hello World +description: Your first document +--- + +Welcome to the docs! You can start writing documents in `/content/docs`. + +## What is Next? + + + + + diff --git a/content/docs/test.mdx b/content/docs/test.mdx new file mode 100644 index 0000000..d1ee3a8 --- /dev/null +++ b/content/docs/test.mdx @@ -0,0 +1,17 @@ +--- +title: Components +description: Components +--- + +## Code Block + +```js +console.log('Hello World'); +``` + +## Cards + + + + + diff --git a/next.config.mjs b/next.config.mjs new file mode 100644 index 0000000..457dcf2 --- /dev/null +++ b/next.config.mjs @@ -0,0 +1,10 @@ +import { createMDX } from 'fumadocs-mdx/next'; + +const withMDX = createMDX(); + +/** @type {import('next').NextConfig} */ +const config = { + reactStrictMode: true, +}; + +export default withMDX(config); diff --git a/package.json b/package.json new file mode 100644 index 0000000..23cbf21 --- /dev/null +++ b/package.json @@ -0,0 +1,38 @@ +{ + "name": "docs", + "version": "0.0.0", + "scripts": { + "build": "next build", + "dev": "next dev", + "start": "next start", + "postinstall": "fumadocs-mdx" + }, + "dependencies": { + "next": "^14.2.8", + "fumadocs-ui": "13.4.8", + "fumadocs-core": "13.4.8", + "react": "^18.3.1", + "react-dom": "^18.3.1", + "fumadocs-mdx": "10.0.2" + }, + "devDependencies": { + "@types/node": "22.5.4", + "@types/react": "^18.3.5", + "@types/react-dom": "^18.3.0", + "typescript": "^5.5.4", + "@types/mdx": "^2.0.13", + "autoprefixer": "^10.4.20", + "postcss": "^8.4.45", + "tailwindcss": "^3.4.10" + }, + "prettier": { + "plugins": [ + "prettier-plugin-tailwindcss" + ], + "useTabs": true, + "semi": false, + "trailingComma": "none", + "printWidth": 120, + "arrowParens": "avoid" + } +} diff --git a/postcss.config.js b/postcss.config.js new file mode 100644 index 0000000..941cff2 --- /dev/null +++ b/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {} + } +} diff --git a/readme.md b/readme.md new file mode 100644 index 0000000..1f084fb --- /dev/null +++ b/readme.md @@ -0,0 +1,26 @@ +# [Docs.Learn-Anything.xyz](https://docs.learn-anything.xyz) + +> Docs, API and all things you can know about LA + +Published using [Fumadocs](https://fumadocs.vercel.app/). + +## Setup + +Using [Bun](https://bun.sh): + +``` +bun i +``` + +## Run + +``` +bun dev +``` + +## Files + +- [content](content) + - [docs](content/docs) - holds the docs, make or edit `.mdx` files + +[![Discord](https://img.shields.io/badge/Discord-100000?style=flat&logo=discord&logoColor=white&labelColor=black&color=black)](https://discord.com/invite/bxtD8x6aNF) [![X](https://img.shields.io/badge/learnanything-100000?logo=X&color=black)](https://x.com/learnanything_) diff --git a/source.config.ts b/source.config.ts new file mode 100644 index 0000000..6ce0ea6 --- /dev/null +++ b/source.config.ts @@ -0,0 +1,5 @@ +import { defineDocs, defineConfig } from "fumadocs-mdx/config" + +export const { docs, meta } = defineDocs() + +export default defineConfig() diff --git a/tailwind.config.js b/tailwind.config.js new file mode 100644 index 0000000..7e53b55 --- /dev/null +++ b/tailwind.config.js @@ -0,0 +1,13 @@ +import { createPreset } from "fumadocs-ui/tailwind-plugin" + +/** @type {import('tailwindcss').Config} */ +export default { + content: [ + "./components/**/*.{ts,tsx}", + "./app/**/*.{ts,tsx}", + "./content/**/*.{md,mdx}", + "./mdx-components.{ts,tsx}", + "./node_modules/fumadocs-ui/dist/**/*.js" + ], + presets: [createPreset()] +} diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..3671b0b --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,29 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "target": "ESNext", + "lib": ["dom", "dom.iterable", "esnext"], + "allowJs": true, + "skipLibCheck": true, + "strict": true, + "forceConsistentCasingInFileNames": true, + "noEmit": true, + "esModuleInterop": true, + "module": "esnext", + "moduleResolution": "node", + "resolveJsonModule": true, + "isolatedModules": true, + "jsx": "preserve", + "incremental": true, + "paths": { + "@/*": ["./*"] + }, + "plugins": [ + { + "name": "next" + } + ] + }, + "include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"], + "exclude": ["node_modules"] +}