forked from mui/base-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/master' into feat/accordion
- Loading branch information
Showing
5 changed files
with
94 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,18 @@ | ||
import * as React from 'react'; | ||
|
||
import { AppBar } from 'docs-base/src/components/AppBar'; | ||
import { Navigation } from 'docs-base/src/components/Navigation'; | ||
import routes from 'docs-base/data/pages'; | ||
import classes from './(content)/styles.module.css'; | ||
|
||
export default function NotFound() { | ||
return <h1>Page not found</h1>; | ||
return ( | ||
<React.Fragment> | ||
<AppBar /> | ||
<Navigation routes={routes} /> | ||
<main className={classes.content}> | ||
<h1>Page not found</h1> | ||
</main> | ||
</React.Fragment> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import * as React from 'react'; | ||
import { type Metadata } from 'next'; | ||
import { notFound } from 'next/navigation'; | ||
import { type Dirent } from 'node:fs'; | ||
import { basename, extname } from 'node:path'; | ||
import { readdir } from 'node:fs/promises'; | ||
|
||
interface Props { | ||
params: { | ||
slug: string; | ||
}; | ||
} | ||
|
||
const DUMMY_SLUG = '_'; | ||
|
||
export default async function Page(props: Props) { | ||
const { | ||
params: { slug }, | ||
} = props; | ||
|
||
if (slug === DUMMY_SLUG) { | ||
notFound(); | ||
} | ||
|
||
try { | ||
const Playground = (await import(`../${slug}.tsx`)).default; | ||
return <Playground />; | ||
} catch (error) { | ||
notFound(); | ||
} | ||
} | ||
|
||
export async function generateStaticParams() { | ||
const routes = (await readdir('app/playground', { withFileTypes: true })) | ||
.filter( | ||
(entry: Dirent) => entry.name.endsWith('.tsx') && entry.name !== 'page.tsx' && entry.isFile(), | ||
) | ||
.map((entry: Dirent) => ({ slug: basename(entry.name, extname(entry.name)) })); | ||
|
||
if (routes.length === 0) { | ||
return [{ slug: DUMMY_SLUG }]; | ||
} | ||
|
||
return routes; | ||
} | ||
|
||
export async function generateMetadata({ params }: Props): Promise<Metadata> { | ||
const { slug } = params; | ||
|
||
return { | ||
title: `${slug} - Playground`, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters