diff --git a/.env b/.env new file mode 100644 index 00000000..97c7098b --- /dev/null +++ b/.env @@ -0,0 +1 @@ +MDX=docs diff --git a/package.json b/package.json index d66c80f0..1b9a5a9a 100644 --- a/package.json +++ b/package.json @@ -22,9 +22,7 @@ "@tailwindcss/typography": "^0.5.4", "clsx": "^1.2.1", "gray-matter": "^4.0.2", - "isomorphic-git": "^1.19.1", "match-sorter": "^6.3.1", - "memfs": "^3.4.7", "next": "^14.2.5", "next-mdx-remote": "^4.4.1", "p-memoize": "^7.1.1", diff --git a/readme.md b/readme.md index 3c84782b..7f0a074f 100644 --- a/readme.md +++ b/readme.md @@ -1,8 +1,14 @@ -# Poimandres Docs +```sh +$ MDX=docs LIBNAME="React Three Fiber" yarn dev +``` -```bash -yarn -yarn dev +```sh +$ MDX=docs LIBNAME="React Three Fiber" yarn build ``` -[![Powered by Vercel](public/vercel.svg)](https://vercel.com/?utm_source=pmndrs&utm_campaign=oss) +| var | description | default | +| ----------- | --------------------------------------------------------- | ------- | +| `MDX` | Path to `*.mxd` folder
NB: can be relative or absolute | `docs` | +| `LIBNAME`\* | Library name | none | + +\* Required diff --git a/src/app/[[...slug]]/DocsContext.tsx b/src/app/[[...slug]]/DocsContext.tsx index 2ec1f25c..9632ebf3 100644 --- a/src/app/[[...slug]]/DocsContext.tsx +++ b/src/app/[[...slug]]/DocsContext.tsx @@ -18,7 +18,7 @@ export type DocToC = { export type Doc = { slug: string[] url: string - editURL: string + // editURL: string nav: number title: string description: string diff --git a/src/app/[[...slug]]/layout.tsx b/src/app/[[...slug]]/layout.tsx index 1ba9ac11..4ef35677 100644 --- a/src/app/[[...slug]]/layout.tsx +++ b/src/app/[[...slug]]/layout.tsx @@ -1,6 +1,5 @@ import clsx from 'clsx' import * as React from 'react' -import LibSwitcher from '@/components/LibSwitcher' import Nav from '@/components/Nav' import Icon from '@/components/Icon' import Toc from '@/components/Toc' @@ -11,10 +10,8 @@ import { useLockBodyScroll } from '@/hooks/useLockBodyScroll' import ToggleTheme from '@/components/ToggleTheme' -import { Doc, DocsContext } from './DocsContext' -import libraries from '@/data/libraries' -import { notFound } from 'next/navigation' -import { getData, getDocs } from '@/utils/docs' +import { DocsContext } from './DocsContext' +import { getData } from '@/utils/docs' export type Props = { params: { slug: string[] } @@ -24,15 +21,8 @@ export type Props = { export default async function Layout({ params, children }: Props) { const slug = params.slug - // 404 - if (!(slug[0] in libraries)) { - return notFound() - } - const asPath = `/${slug.join('/')}` - const lib = slug[0] - const { docs, doc } = await getData(...slug) // console.log('docs', docs) @@ -47,6 +37,8 @@ export default async function Layout({ params, children }: Props) { // React.useEffect(() => setMenuOpen(false), [asPath]) + const { LIBNAME } = process.env + return ( <> @@ -54,7 +46,7 @@ export default async function Layout({ params, children }: Props) {
- Pmndrs + pmndrs .docs
@@ -89,7 +81,11 @@ export default async function Layout({ params, children }: Props) { className="overflow-y-auto px-4 font-medium text-base lg:text-sm pb-10 lg:pb-14 sticky?lg:h-(screen-16) z-10 relative" >
- + {LIBNAME?.length && ( + + {LIBNAME} + + )}
@@ -114,7 +110,7 @@ export default async function Layout({ params, children }: Props) {
{children}