-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui/docs): add devdocs site with content
- Loading branch information
1 parent
d580558
commit 569e003
Showing
19 changed files
with
2,338 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
/** Auto-generated */ | ||
declare const map: Record<string, unknown> | ||
|
||
export { map } |
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,29 @@ | ||
import type { MDXComponents } from 'mdx/types' | ||
import defaultComponents from 'fumadocs-ui/mdx' | ||
import type { ReactNode } from 'react' | ||
import { Tab, Tabs } from 'fumadocs-ui/components/tabs' | ||
import { Step, Steps } from 'fumadocs-ui/components/steps' | ||
import { Callout } from 'fumadocs-ui/components/callout' | ||
|
||
export function useMDXComponents(components: MDXComponents): MDXComponents { | ||
return { | ||
...defaultComponents, | ||
...components, | ||
Tab, | ||
Tabs, | ||
InstallTabs: ({ | ||
items, | ||
children, | ||
}: { | ||
items: string[] | ||
children: ReactNode | ||
}) => ( | ||
<Tabs items={items} id="package-manager"> | ||
{children} | ||
</Tabs> | ||
), | ||
Step, | ||
Steps, | ||
Callout, | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { createSearchAPI } from 'fumadocs-core/search/server' | ||
import { getPages } from '@/app/docs/source' | ||
|
||
export const { GET } = createSearchAPI('advanced', { | ||
indexes: getPages().map(page => ({ | ||
title: page.data.title, | ||
structuredData: page.data.exports.structuredData, | ||
id: page.url, | ||
url: page.url, | ||
})), | ||
}) |
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,72 @@ | ||
import type { Metadata } from 'next' | ||
import { DocsBody, DocsPage } from 'fumadocs-ui/page' | ||
import { notFound } from 'next/navigation' | ||
import { Edit } from 'lucide-react' | ||
import packageJson from '@root/package.json' | ||
import { getPage, getPages } from '@/app/docs/source' | ||
|
||
export default async function Page({ | ||
params, | ||
}: { | ||
params: { slug?: string[] } | ||
}) { | ||
const page = getPage(params.slug) | ||
|
||
if (page == null) { | ||
notFound() | ||
} | ||
|
||
const MDX = page.data.exports.default | ||
const path = `src/content/docs/${page.file.path}` | ||
const gitHubRepoUrl = packageJson.repository.url.replace(/\.git$/, '') // Remove .git suffix | ||
|
||
const footer = ( | ||
<a | ||
href={`${gitHubRepoUrl}/blob/main/${path}`} | ||
target="_blank" | ||
rel="noreferrer noopener" | ||
className="inline-flex items-center justify-center rounded-md font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:pointer-events-none disabled:opacity-50 border bg-secondary text-secondary-foreground hover:bg-secondary/80 h-9 px-3 text-xs gap-1.5" | ||
> | ||
<Edit className="size-3" /> | ||
Edit on GitHub | ||
</a> | ||
) | ||
|
||
return ( | ||
<DocsPage | ||
toc={page.data.exports.toc} | ||
lastUpdate={page.data.exports.lastModified} | ||
full={page.data.full} | ||
tableOfContent={{ | ||
footer, | ||
}} | ||
tableOfContentPopover={{ footer }} | ||
> | ||
<DocsBody> | ||
<h1>{page.data.title}</h1> | ||
<p className="mb-8 text-lg text-muted-foreground"> | ||
{page.data.description} | ||
</p> | ||
<MDX /> | ||
</DocsBody> | ||
</DocsPage> | ||
) | ||
} | ||
|
||
export async function generateStaticParams() { | ||
return getPages().map(page => ({ | ||
slug: page.slugs, | ||
})) | ||
} | ||
|
||
export function generateMetadata({ params }: { params: { slug?: string[] } }) { | ||
const page = getPage(params.slug) | ||
|
||
if (page == null) | ||
notFound() | ||
|
||
return { | ||
title: page.data.title, | ||
description: page.data.description, | ||
} satisfies Metadata | ||
} |
Binary file not shown.
Oops, something went wrong.