diff --git a/.env b/.env deleted file mode 100644 index e9dfd7ad..00000000 --- a/.env +++ /dev/null @@ -1 +0,0 @@ -MDX=docs \ No newline at end of file diff --git a/readme.md b/readme.md index c37544cc..ecc642e2 100644 --- a/readme.md +++ b/readme.md @@ -23,7 +23,7 @@ http://localhost:3000/getting-started/introduction | var | description | default | | ----------------------- | --------------------------------------------------------- | ------- | -| `MDX` | Path to `*.mdx` folder
NB: can be relative or absolute | `docs` | +| `MDX`\* | Path to `*.mdx` folder
NB: can be relative or absolute | none | | `NEXT_PUBLIC_LIBNAME`\* | Library name | none | | `BASE_PATH` | base path for the final URL | none | | `DIST_DIR` | Path to the output folder | `out` | diff --git a/src/app/[[...slug]]/DocsContext.tsx b/src/app/[...slug]/DocsContext.tsx similarity index 100% rename from src/app/[[...slug]]/DocsContext.tsx rename to src/app/[...slug]/DocsContext.tsx diff --git a/src/app/[[...slug]]/Menu.tsx b/src/app/[...slug]/Menu.tsx similarity index 100% rename from src/app/[[...slug]]/Menu.tsx rename to src/app/[...slug]/Menu.tsx diff --git a/src/app/[[...slug]]/MenuContext.tsx b/src/app/[...slug]/MenuContext.tsx similarity index 100% rename from src/app/[[...slug]]/MenuContext.tsx rename to src/app/[...slug]/MenuContext.tsx diff --git a/src/app/[[...slug]]/layout.tsx b/src/app/[...slug]/layout.tsx similarity index 100% rename from src/app/[[...slug]]/layout.tsx rename to src/app/[...slug]/layout.tsx diff --git a/src/app/[[...slug]]/page.tsx b/src/app/[...slug]/page.tsx similarity index 96% rename from src/app/[[...slug]]/page.tsx rename to src/app/[...slug]/page.tsx index ed81f3ab..4c2051cc 100644 --- a/src/app/[[...slug]]/page.tsx +++ b/src/app/[...slug]/page.tsx @@ -55,7 +55,10 @@ export async function generateStaticParams() { // ] const MDX = process.env.MDX - if (!MDX) throw new Error('MDX env var not set') + if (!MDX) { + console.warn('MDX env var not set') + return [] + } const docs = await getDocs(MDX, null, true) const paths = docs.map(({ slug }) => ({ slug })) diff --git a/src/app/page.tsx b/src/app/page.tsx new file mode 100644 index 00000000..8d6cb1b6 --- /dev/null +++ b/src/app/page.tsx @@ -0,0 +1,186 @@ +import Link from 'next/link' +import Image from 'next/image' + +import reactThreeFiberShare from '@/assets/react-three-fiber.jpg' +import zustandShare from '@/assets/zustand.jpg' +import zustandIcon from '@/assets/zustand-icon.png' +import jotaiIcon from '@/assets/jotai-icon.png' +import reactThreeA11yShare from '@/assets/react-three-a11y.jpg' +import reactPostprocessingShare from '@/assets/react-postprocessing.jpg' +import Icon from '@/components/Icon' +import { redirect } from 'next/navigation' + +export interface Library { + title: string + url: string + github: string + description: string + // Optional banner image + image?: string + // Optional project icon + icon?: string + iconWidth?: number + iconHeight?: number + // Optional repository to fetch and serve docs from + // /// + docs?: string +} + +const libs: Record = { + 'react-three-fiber': { + title: 'React Three Fiber', + url: '/react-three-fiber', + github: 'https://github.com/pmndrs/react-three-fiber', + description: 'React-three-fiber is a React renderer for three.js', + image: reactThreeFiberShare.src, + docs: 'pmndrs/react-three-fiber/master/docs', + }, + 'react-spring': { + title: 'React Spring', + url: 'https://react-spring.io', + github: 'https://github.com/pmndrs/react-spring', + description: 'Bring your components to life with simple spring animation primitives for React', + }, + drei: { + title: 'Drei', + url: 'https://github.com/pmndrs/drei#readme', + github: 'https://github.com/pmndrs/drei', + description: + 'Drei is a growing collection of useful helpers and abstractions for react-three-fiber', + }, + zustand: { + title: 'Zustand', + url: '/zustand', + github: 'https://github.com/pmndrs/zustand', + description: + 'Zustand is a small, fast and scalable bearbones state-management solution, it has a comfy api based on hooks', + icon: zustandIcon.src, + iconWidth: zustandIcon.width, + iconHeight: zustandIcon.height, + image: zustandShare.src, + docs: 'pmndrs/zustand/main/docs', + }, + jotai: { + title: 'Jotai', + url: 'https://jotai.org/docs/introduction', + github: 'https://github.com/pmndrs/jotai', + description: 'Jotai is a primitive and flexible state management library for React', + icon: jotaiIcon.src, + iconWidth: jotaiIcon.width, + iconHeight: jotaiIcon.height, + }, + valtio: { + title: 'Valtio', + url: 'https://valtio.pmnd.rs', + github: 'https://github.com/pmndrs/valtio', + description: 'Valtio makes proxy-state simple for React and Vanilla', + }, + a11y: { + title: 'A11y', + url: '/a11y', + github: 'https://github.com/pmndrs/react-three-a11y', + description: + '@react-three/a11y brings accessibility to webGL with easy-to-use react-three-fiber components', + image: reactThreeA11yShare.src, + docs: 'pmndrs/react-three-a11y/main/docs', + }, + 'react-postprocessing': { + title: 'React Postprocessing', + url: '/react-postprocessing', + github: 'https://github.com/pmndrs/react-postprocessing', + description: 'React Postprocessing is a postprocessing wrapper for @react-three/fiber', + image: reactPostprocessingShare.src, + docs: 'pmndrs/react-postprocessing/master/docs', + }, + uikit: { + title: 'uikit', + url: '/uikit', + github: 'https://github.com/pmndrs/uikit', + description: 'uikit brings user interfaces to @react-three/fiber', + docs: 'pmndrs/uikit/main/docs', + }, + xr: { + title: 'xr', + url: '/xr', + github: 'https://github.com/pmndrs/xr', + description: 'VR/AR for @react-three/fiber', + docs: 'pmndrs/xr/main/docs', + }, +} + +export default function Page() { + if (process.env.OUTPUT === 'export') redirect('/getting-started/introduction') + + return ( + <> +
+
+
+ + Pmndrs + .docs + + {/* */} +
+
+
+
+ {Object.entries(libs).map(([id, data]) => ( +
+
+
+
+
{data.title}
+
+ {data.description} +
+
+ {data.icon && ( +
+ + {data.title} + +
+ )} +
+
+ + + + Docs + Documentation + + + + + GitHub + +
+
+
+ ))} +
+
+
+ + ) +} diff --git a/src/components/Nav.tsx b/src/components/Nav.tsx index 07158f7d..c553a937 100644 --- a/src/components/Nav.tsx +++ b/src/components/Nav.tsx @@ -1,7 +1,7 @@ import * as React from 'react' import clsx from 'clsx' import Link from 'next/link' -import { Doc } from '@/app/[[...slug]]/DocsContext' +import { Doc } from '@/app/[...slug]/DocsContext' interface NavItemProps { doc: Doc diff --git a/src/components/Post.tsx b/src/components/Post.tsx index 53dad3e2..e1b43338 100644 --- a/src/components/Post.tsx +++ b/src/components/Post.tsx @@ -1,4 +1,4 @@ -import { Doc } from '@/app/[[...slug]]/DocsContext' +import { Doc } from '@/app/[...slug]/DocsContext' export default async function Post({ doc }: { doc: Doc }) { return <>{doc.content} diff --git a/src/components/Search/SearchModalContainer.tsx b/src/components/Search/SearchModalContainer.tsx index fe656f0e..01a05f87 100644 --- a/src/components/Search/SearchModalContainer.tsx +++ b/src/components/Search/SearchModalContainer.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import { useRouter } from 'next/navigation' import { matchSorter } from 'match-sorter' -import { useDocs } from '@/app/[[...slug]]/DocsContext' +import { useDocs } from '@/app/[...slug]/DocsContext' import SearchModal from './SearchModal' import type { SearchResult } from './SearchItem' diff --git a/src/components/Toc.tsx b/src/components/Toc.tsx index acd1851c..8569a875 100644 --- a/src/components/Toc.tsx +++ b/src/components/Toc.tsx @@ -2,7 +2,7 @@ import * as React from 'react' import clsx from 'clsx' -import type { DocToC } from '@/app/[[...slug]]/DocsContext' +import type { DocToC } from '@/app/[...slug]/DocsContext' export interface ToCProps { toc: DocToC[] diff --git a/src/utils/docs.tsx b/src/utils/docs.tsx index 34056fe8..aaf10a48 100644 --- a/src/utils/docs.tsx +++ b/src/utils/docs.tsx @@ -1,7 +1,7 @@ import fs from 'node:fs' import matter from 'gray-matter' -import type { Doc, DocToC } from '@/app/[[...slug]]/DocsContext' +import type { Doc, DocToC } from '@/app/[...slug]/DocsContext' import { cache } from 'react' import { compileMDX } from 'next-mdx-remote/rsc' diff --git a/src/utils/rehype.ts b/src/utils/rehype.ts index f61643c2..22de2a22 100644 --- a/src/utils/rehype.ts +++ b/src/utils/rehype.ts @@ -1,4 +1,4 @@ -import type { DocToC } from '@/app/[[...slug]]/DocsContext' +import type { DocToC } from '@/app/[...slug]/DocsContext' export interface Node { type: string