Skip to content

Commit 6ed3fc9

Browse files
marklundinCopilot
andauthored
Refactor documentation structure and remove unused components (#121)
* Refactor documentation structure and remove unused components - Updated import paths for ReactQueryProvider and other components to ensure consistency. - Deleted unused files and components, including various example pages and utility functions, to streamline the codebase. - Adjusted TypeScript configuration for improved module resolution. - Enhanced overall organization of the documentation structure for better clarity and maintainability. * Update packages/docs/app/[[...mdxPath]]/page.tsx Co-authored-by: Copilot <[email protected]> * Update packages/docs/content/_meta.tsx Co-authored-by: Copilot <[email protected]> * Update packages/docs/app/[[...mdxPath]]/page.tsx Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]>
1 parent e92dd50 commit 6ed3fc9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

81 files changed

+306
-465
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
import { generateStaticParamsFor, importPage } from 'nextra/pages'
2+
import { useMDXComponents as getMDXComponents } from '../../mdx-components'
3+
import { readFile } from 'node:fs/promises'
4+
import path from 'node:path'
5+
import Playground from '@docs-components/Playground'
6+
7+
export const generateStaticParams = generateStaticParamsFor('mdxPath')
8+
const EXAMPLES_PATH = 'examples'
9+
10+
export async function generateMetadata(props) {
11+
const params = await props.params
12+
13+
const isExamples = params.mdxPath[0] === EXAMPLES_PATH;
14+
15+
if (isExamples) {
16+
const fileName = params.mdxPath.slice(-1)[0];
17+
const contentPath = params.mdxPath.slice(0, 1);
18+
19+
const source = await readFile(
20+
path.join(process.cwd(), 'content', ...contentPath, `${fileName}.meta.json`),
21+
'utf-8'
22+
)
23+
24+
// We can't dynamically import with the full path. An error is thrown because the import is too dynamic.
25+
// const metaPath = path.join('@content', 'examples', `${fileName}.meta.tsx`)
26+
// const { default: metadata } = await import(metaPath);
27+
return JSON.parse(source);
28+
}
29+
30+
const { metadata } = await importPage(params.mdxPath)
31+
return metadata
32+
}
33+
34+
const Wrapper = getMDXComponents().wrapper
35+
36+
export default async function Page(props) {
37+
const params = await props.params
38+
39+
const { default: MDXContent, toc, metadata } = await importPage(params.mdxPath)
40+
const isExamples = params.mdxPath[0] === EXAMPLES_PATH;
41+
42+
if (isExamples) {
43+
const contentPath = params.mdxPath.slice(0, 1);
44+
const fileName = params.mdxPath.slice(-1)[0];
45+
46+
const source = await readFile(
47+
path.join(process.cwd(), 'content', ...contentPath, `${fileName}.mdx`),
48+
'utf-8'
49+
)
50+
51+
return (
52+
<div className='absolute top-0 left-0 w-screen h-screen pointer-events-none'>
53+
<Playground name={`./${params.mdxPath}.tsx`} code={source} path={metadata.filePath}/>
54+
</div>
55+
)
56+
}
57+
58+
return (
59+
<Wrapper toc={toc} metadata={metadata}>
60+
<MDXContent {...props} params={params} />
61+
</Wrapper>
62+
)
63+
}
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Footer, Layout, Navbar } from 'nextra-theme-docs'
66
import { Banner, Head } from 'nextra/components'
77
import { getPageMap } from 'nextra/page-map'
88
import { CodeXml } from 'lucide-react'
9-
import ReactQueryProvider from '@/docs-components/ReactQueryProvider'
9+
import ReactQueryProvider from '@docs-components/ReactQueryProvider'
1010

1111
export const metadata = {
1212
metadataBase: new URL('https://playcanvas.com'),
@@ -61,7 +61,7 @@ export default async function RootLayout({ children }: { children: React.ReactNo
6161
MIT {new Date().getFullYear()} ©{' '} PlayCanvas.
6262
</Footer>}
6363
editLink="Edit this page on GitHub"
64-
docsRepositoryBase="https://github.com/playcanvas/react/tree/main/packages/docs/"
64+
docsRepositoryBase="https://github.com/playcanvas/react/tree/main/packages/docs"
6565
sidebar={{
6666
defaultMenuCollapseLevel: 1,
6767
toggleButton: true

packages/docs/client-mdx-components.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Application, Entity } from '@playcanvas/react'
22
import { OrbitControls } from '@playcanvas/react/scripts'
33
import { Align, Light, Anim, Camera, Collision, EnvAtlas, GSplat, Script, Render, RigidBody } from '@playcanvas/react/components'
44

5-
import ReactQueryProvider from '@/docs-components/ReactQueryProvider'
5+
import ReactQueryProvider from '@docs-components/ReactQueryProvider'
66

77
import EnvAtlasComponent from '@components/EnvAtlas'
88
import Grid from '@components/Grid'
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)