-
Notifications
You must be signed in to change notification settings - Fork 0
feat(docs): initialize fumadocs #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c2d001a
feat(docs): initialize fumadocs
mezotv 0e12b42
style: format files
mezotv 2343e2e
fix: remove source
mezotv 3639d60
fix: ignore source files
mezotv cadc892
Merge branch 'feat/component-docs' of https://github.com/Would-You-Bo…
mezotv 4045ff9
chore(deps): bump pnpm ver
tobias-hay c371d5d
chore(docs/og): update og color
tobias-hay f2bc4f2
chore(docs): fix linting issues
tobias-hay bb65388
chore(docs): remove a 'dark:' color
tobias-hay 078b8da
fix(docs/styles): move extra root into root already there
tobias-hay 50f90ec
fix: remove unused css rule
mezotv File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 type { ReactNode } from "react"; | ||
| import { HomeLayout } from "fumadocs-ui/layouts/home"; | ||
| import { baseOptions } from "@/app/layout.config"; | ||
|
|
||
| export default function Layout({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <HomeLayout {...baseOptions}> | ||
| <div className="bg-background pt-8 md:pt-16">{children}</div> | ||
| </HomeLayout> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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,6 @@ | ||
| import { source } from "@/lib/source"; | ||
| import { createFromSource } from "fumadocs-core/search/server"; | ||
|
|
||
| export const { GET } = createFromSource(source, { | ||
| language: "english" | ||
| }); |
This file contains hidden or 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,108 @@ | ||
| import { source } from "@/lib/source"; | ||
| import { | ||
| DocsPage, | ||
| DocsBody, | ||
| DocsDescription, | ||
| DocsTitle | ||
| } from "fumadocs-ui/page"; | ||
| import { notFound } from "next/navigation"; | ||
| import { createRelativeLink } from "fumadocs-ui/mdx"; | ||
| import { getMDXComponents } from "@/mdx-components"; | ||
| import { getGithubLastEdit, getPageTreePeers } from "fumadocs-core/server"; | ||
| import type { Metadata } from "next"; | ||
| import { Card, Cards } from "fumadocs-ui/components/card"; | ||
|
|
||
| export default async function Page(props: { | ||
| params: Promise<{ slug?: string[] }>; | ||
| }) { | ||
| const params = await props.params; | ||
| const page = source.getPage(params.slug); | ||
| if (!page) { | ||
| notFound(); | ||
| } | ||
|
|
||
| const MDXContent = page.data.body; | ||
|
|
||
| const time = await getGithubLastEdit({ | ||
| owner: "Would-You-Bot", | ||
| repo: "discord-components", | ||
| path: `content/docs/${page.path}` | ||
| }); | ||
|
|
||
| return ( | ||
| <DocsPage | ||
| toc={page.data.toc} | ||
| full={page.data.full} | ||
| tableOfContent={{ | ||
| style: "clerk" | ||
| }} | ||
| lastUpdate={time ? new Date(time) : undefined} | ||
| > | ||
| <DocsTitle>{page.data.title}</DocsTitle> | ||
| <DocsDescription>{page.data.description}</DocsDescription> | ||
| <DocsBody> | ||
| <MDXContent | ||
| components={getMDXComponents({ | ||
| // this allows you to link to other pages with relative file paths | ||
| a: createRelativeLink(source, page), | ||
| DocsCategory: ({ url }) => { | ||
| return <DocsCategory url={url ?? page.url} />; | ||
| } | ||
| })} | ||
| /> | ||
| </DocsBody> | ||
| </DocsPage> | ||
| ); | ||
| } | ||
|
|
||
| function DocsCategory({ url }: { url: string }) { | ||
| return ( | ||
| <Cards> | ||
| {getPageTreePeers(source.pageTree, url).map((peer) => ( | ||
| <Card | ||
| key={peer.url} | ||
| title={peer.name} | ||
| href={peer.url} | ||
| > | ||
| {peer.description} | ||
| </Card> | ||
| ))} | ||
| </Cards> | ||
| ); | ||
| } | ||
|
|
||
| export function generateStaticParams() { | ||
| return source.generateParams(); | ||
| } | ||
|
|
||
| export async function generateMetadata(props: { | ||
| params: Promise<{ slug: string[] }>; | ||
| }): Promise<Metadata> { | ||
| const { slug = [] } = await props.params; | ||
| const page = source.getPage(slug); | ||
| if (!page) { | ||
| notFound(); | ||
| } | ||
|
|
||
| const description = | ||
| page.data.description || | ||
| "A collection of discord components for integrating discord UIs into your project."; | ||
|
|
||
| const image = { | ||
| url: ["/og", ...slug, "image.png"].join("/"), | ||
| width: 1200, | ||
| height: 630 | ||
| }; | ||
|
|
||
| return { | ||
| title: `${page.data.title} | Discord Components`, | ||
| description, | ||
| openGraph: { | ||
| images: [image] | ||
| }, | ||
| twitter: { | ||
| card: "summary_large_image", | ||
| images: [image] | ||
| } | ||
| }; | ||
| } |
This file contains hidden or 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,15 @@ | ||
| import { DocsLayout } from "fumadocs-ui/layouts/docs"; | ||
| import type { ReactNode } from "react"; | ||
| import { baseOptions } from "@/app/layout.config"; | ||
| import { source } from "@/lib/source"; | ||
|
|
||
| export default function Layout({ children }: { children: ReactNode }) { | ||
| return ( | ||
| <DocsLayout | ||
| tree={source.pageTree} | ||
| {...baseOptions} | ||
| > | ||
| {children} | ||
| </DocsLayout> | ||
| ); | ||
| } |
This file contains hidden or 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 hidden or 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,33 @@ | ||
| import type { BaseLayoutProps } from "fumadocs-ui/layouts/shared"; | ||
| import { Inter } from "next/font/google"; | ||
|
|
||
| const inter = Inter({ | ||
| subsets: ["latin"], | ||
| weight: ["400", "500", "600", "700"] | ||
| }); | ||
|
|
||
| /** | ||
| * Shared layout configurations | ||
| * | ||
| * you can customise layouts individually from: | ||
| * Home Layout: app/(home)/layout.tsx | ||
| * Docs Layout: app/docs/layout.tsx | ||
| */ | ||
| export const baseOptions: BaseLayoutProps = { | ||
| themeSwitch: { | ||
| enabled: false, // TODO: Add better theme colors | ||
| mode: "light-dark" | ||
| }, | ||
| nav: { | ||
| title: ( | ||
| <> | ||
| <div className={`${inter.className} font-bold text-2xl`}> | ||
| Discord Components | ||
| </div> | ||
| </> | ||
| ) | ||
| }, | ||
| // see https://fumadocs.dev/docs/ui/navigation/links | ||
| links: [], | ||
| githubUrl: "https://github.com/Would-You-Bot/discord-components" | ||
| }; | ||
This file contains hidden or 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
Binary file not shown.
Binary file not shown.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.