Repository navigation
refactor: Docs layout #859
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
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
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
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,18 @@ | ||
| import type React from 'react' | ||
|
|
||
| import { cn } from 'cn' | ||
| import { Card as FumadocsCard } from 'fumadocs-ui/components/card' | ||
|
|
||
| export const Card = ({ | ||
| className, | ||
| href, | ||
| icon, | ||
| ...props | ||
| }: React.ComponentProps<typeof FumadocsCard>) => ( | ||
| <FumadocsCard | ||
| className={cn(href && 'hover:border-fd-primary/60', className)} | ||
| href={href} | ||
| icon={icon ? <span className="text-fd-primary flex">{icon}</span> : null} | ||
| {...props} | ||
| /> | ||
| ) |
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 |
|---|---|---|
| @@ -1,5 +1,19 @@ | ||
| @import '../styles.css'; | ||
| @import 'fumadocs-ui/css/generated/spacious.css'; | ||
| @import 'fumadocs-ui/css/shadcn.css'; | ||
| @import 'fumadocs-ui/css/preset.css'; | ||
|
|
||
| @source '../../node_modules/fumadocs-ui/dist/**/*.js'; | ||
|
|
||
| :root:not(.dark) #fd-spacious-layout { | ||
| background-color: var(--color-fd-background); | ||
| } | ||
|
|
||
| :root:not(.dark) #nd-sidebar { | ||
| background-color: var(--background); | ||
| --color-fd-accent: var(--accent); | ||
| } | ||
|
|
||
| :root:not(.dark) #fd-spacious-layout .prose { | ||
| --tw-prose-body: oklch(0.373 0.003 264); | ||
| } |
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
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,51 @@ | ||
| import { usePathname } from 'fumadocs-core/framework' | ||
| import Link from 'fumadocs-core/link' | ||
| import { findNeighbour } from 'fumadocs-core/page-tree' | ||
| import { useTreeContext } from 'fumadocs-ui/contexts/tree' | ||
| import { ArrowLeft, ArrowRight } from 'lucide-react' | ||
|
|
||
| export const DocsPageFooter = () => { | ||
| const { full } = useTreeContext() | ||
| const { next, previous } = findNeighbour(full, usePathname()) | ||
|
|
||
| if (!(next || previous)) return null | ||
|
|
||
| return ( | ||
| <nav | ||
| aria-label="Previous and next page" | ||
| className="mt-10 flex flex-col gap-4" | ||
| > | ||
| {next && ( | ||
| <Link | ||
| className="group border-fd-primary/20 bg-fd-primary/5 hover:bg-fd-primary/10 flex items-center justify-between gap-6 rounded-2xl border p-5 transition-colors md:p-6" | ||
| href={next.url} | ||
| > | ||
| <span className="flex min-w-0 flex-col gap-1"> | ||
| <span className="text-fd-primary text-sm font-medium">Next up</span> | ||
| <span className="text-fd-foreground text-lg font-semibold text-balance"> | ||
| {next.name} | ||
| </span> | ||
| {next.description && ( | ||
| <span className="text-fd-muted-foreground text-sm leading-relaxed text-pretty"> | ||
| {next.description} | ||
| </span> | ||
| )} | ||
| </span> | ||
| <ArrowRight | ||
| aria-hidden="true" | ||
| className="text-fd-primary size-5 shrink-0 transition-transform group-hover:translate-x-0.5 motion-reduce:transition-none" | ||
| /> | ||
| </Link> | ||
| )} | ||
| {previous && ( | ||
| <Link | ||
| className="text-fd-muted-foreground hover:text-fd-foreground inline-flex items-center gap-2 self-start py-2 text-sm transition-colors" | ||
| href={previous.url} | ||
| > | ||
| <ArrowLeft aria-hidden="true" className="size-4" /> | ||
| {previous.name} | ||
| </Link> | ||
| )} | ||
| </nav> | ||
| ) | ||
| } | ||
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,112 @@ | ||
| import type { Folder } from 'fumadocs-core/page-tree' | ||
|
|
||
| import { buttonVariants } from '@vitnode/core/components/ui/button' | ||
| import { CopyButton } from '@vitnode/core/components/ui/copy-button' | ||
| import { useTreePath } from 'fumadocs-ui/contexts/tree' | ||
| import { | ||
| DocsDescription, | ||
| DocsTitle, | ||
| ViewOptionsPopover, | ||
| } from 'fumadocs-ui/layouts/spacious/page' | ||
| import { ChevronRight } from 'lucide-react' | ||
| import { Fragment } from 'react' | ||
|
|
||
| const markdownCache = new Map<string, string>() | ||
|
|
||
| const loadMarkdown = async (markdownUrl: string) => { | ||
| const cached = markdownCache.get(markdownUrl) | ||
| if (cached !== undefined) return cached | ||
|
|
||
| const res = await fetch(markdownUrl) | ||
| if (!res.ok) throw new Error(`Failed to load ${markdownUrl}: ${res.status}`) | ||
|
|
||
| const markdown = await res.text() | ||
| if (import.meta.env.PROD) markdownCache.set(markdownUrl, markdown) | ||
|
|
||
| return markdown | ||
| } | ||
|
|
||
| const SectionPath = ({ folders }: { folders: Folder[] }) => ( | ||
| <p className="text-fd-primary flex flex-wrap items-center gap-1 text-sm font-medium [&_.fd-page-tree-item-name]:w-auto!"> | ||
| {folders.map((folder, index) => ( | ||
| <Fragment key={folder.$id ?? folder.index?.url}> | ||
| {index > 0 && ( | ||
| <ChevronRight aria-hidden="true" className="size-3.5 opacity-60" /> | ||
| )} | ||
| {folder.name} | ||
| </Fragment> | ||
| ))} | ||
| </p> | ||
| ) | ||
|
|
||
| const IconArtwork = ({ icon }: { icon: React.ReactNode }) => ( | ||
| <div | ||
| aria-hidden="true" | ||
| className="relative flex size-40 shrink-0 items-center justify-center select-none max-md:hidden" | ||
| > | ||
| <span className="border-fd-primary/10 absolute inset-0 rounded-4xl border" /> | ||
| <span className="border-fd-primary/15 bg-fd-primary/5 absolute inset-5 rounded-xl border" /> | ||
| <span className="bg-fd-background text-fd-primary relative flex size-20 items-center justify-center rounded-2xl border shadow-sm [&_svg]:size-9"> | ||
| {icon} | ||
| </span> | ||
| </div> | ||
| ) | ||
|
|
||
| export const DocsPageHeader = ({ | ||
| description, | ||
| githubUrl, | ||
| markdownUrl, | ||
| title, | ||
| }: { | ||
| description?: string | ||
| githubUrl: string | ||
| markdownUrl: string | ||
| title: string | ||
| }) => { | ||
| const path = useTreePath() | ||
| const icon = path.at(-1)?.icon | ||
| const sectionPath = path.filter( | ||
| (node): node is Folder => node.type === 'folder' && !node.root, | ||
| ) | ||
|
|
||
| return ( | ||
| <header className="flex items-center gap-10 border-b pt-2 pb-10"> | ||
| <div className="flex min-w-0 flex-1 flex-col gap-4"> | ||
| {(icon || sectionPath.length > 0) && ( | ||
| <div className="flex items-center gap-3"> | ||
| {icon && ( | ||
| <span | ||
| aria-hidden="true" | ||
| className="bg-fd-background text-fd-primary flex size-10 shrink-0 items-center justify-center rounded-xl border shadow-xs md:hidden [&_svg]:size-5" | ||
| > | ||
| {icon} | ||
| </span> | ||
| )} | ||
| {sectionPath.length > 0 && <SectionPath folders={sectionPath} />} | ||
| </div> | ||
| )} | ||
| <DocsTitle className="text-3xl tracking-tight text-balance md:text-4xl"> | ||
| {title} | ||
| </DocsTitle> | ||
| <DocsDescription className="mb-0 text-lg leading-relaxed text-pretty"> | ||
| {description} | ||
| </DocsDescription> | ||
| <div className="flex flex-wrap items-center gap-2 pt-1"> | ||
| <CopyButton | ||
| content={async () => await loadMarkdown(markdownUrl)} | ||
| size="sm" | ||
| variant="secondary" | ||
| > | ||
| Copy Markdown | ||
| </CopyButton> | ||
| <ViewOptionsPopover | ||
| className={buttonVariants({ size: 'sm', variant: 'secondary' })} | ||
| githubUrl={githubUrl} | ||
| markdownUrl={markdownUrl} | ||
| /> | ||
| </div> | ||
| </div> | ||
| {icon && <IconArtwork icon={icon} />} | ||
| </header> | ||
| ) | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The new footer mixes
mt-10withgap-4, and repeats the same pattern withgap-6and padding on the next-page link. Split the outer spacing onto a wrapper or use one spacing mechanism so this component follows the repository's explicit layout convention.AGENTS.md reference: AGENTS.md:L73-L73
Useful? React with 👍 / 👎.