
# Komponenty

Onedocs rejestruje zestaw komponentów Fumadocs UI dla plików MDX, dzięki czemu można ich używać bez importowania.

## Korzystanie z komponentów

Przekaż `mdxComponents` do treści MDX:

```tsx title="src/app/docs/[[...slug]]/page.tsx"
import { DocsPage, mdxComponents } from "onedocs";

// In your page component:
<MDX components={mdxComponents} />
```

`mdxComponents` zawiera domyślne elementy Fumadocs UI (nagłówki z linkami kotwic, bloki kodu, linki, obrazy, tabele, `Card`, `Cards` i `Callout`), a także `Tab`, `Tabs`, `Step`, `Steps`, `Accordion`, `Accordions`, `File`, `Folder`, `Files`, `ImageZoom` i `TypeTable`. Wszystkie poniższe przykłady działają bez zmian.

## Komunikat

Wyróżnia ważne informacje. `type` to jedna z wartości: `info` (domyślna), `warn`, `error`, `success` lub `idea`:

```mdx
<Callout type="info">
  This is an informational callout.
</Callout>

<Callout type="warn">
  This is a warning callout.
</Callout>

<Callout type="error">
  This is an error callout.
</Callout>
```

Dodaj nagłówek za pomocą `title`:

```mdx
<Callout type="warn" title="Breaking change">
  The `docs` option was removed in version 2.
</Callout>
```

## Karty

Porządkuje treść na kartach. Każdy `Tab` `value` odpowiada wpisowi w `items`:

```mdx
<Tabs items={["npm", "yarn", "pnpm", "bun"]}>
  <Tab value="npm">npm install onedocs</Tab>
  <Tab value="yarn">yarn add onedocs</Tab>
  <Tab value="pnpm">pnpm add onedocs</Tab>
  <Tab value="bun">bun add onedocs</Tab>
</Tabs>
```

## Karty

Linkuj do innych stron za pomocą siatek kart:

```mdx
<Cards>
  <Card title="Getting Started" href="/docs/getting-started">
    Learn how to set up Onedocs
  </Card>
  <Card title="Configuration" href="/docs/configuration">
    Configure your documentation
  </Card>
</Cards>
```

## Kroki

Wyświetla numerowane kroki:

```mdx
<Steps>
  <Step>Install Onedocs</Step>
  <Step>Create configuration</Step>
  <Step>Write documentation</Step>
</Steps>
```

## Akordeon

Zwijana treść na potrzeby FAQ i dodatkowych informacji. W danym momencie otwarty jest tylko jeden element:

```mdx
<Accordions>
  <Accordion title="What is Onedocs?">
    Layouts, components and SEO helpers for documentation sites built with Next.js and Fumadocs.
  </Accordion>
  <Accordion title="How do I install it?">
    Follow the install step in Getting Started.
  </Accordion>
</Accordions>
```

## Pliki

Wyświetla drzewa plików:

```mdx
<Files>
  <Folder name="content" defaultOpen>
    <Folder name="docs" defaultOpen>
      <File name="index.mdx" />
      <File name="getting-started.mdx" />
    </Folder>
  </Folder>
  <File name="onedocs.config.ts" />
</Files>
```

## Powiększanie obrazów

Obraz otwierany w pełnym rozmiarze po kliknięciu. Wymagane są `width` i `height` w przypadku obrazów z `public/`:

```mdx
<ImageZoom src="/screenshot.png" alt="Dashboard" width={1200} height={800} />
```

## Tabela typów

Dokumentuje właściwości lub opcje elementu API:

```mdx
<TypeTable
  type={{
    title: {
      type: "string",
      description: "Site name shown in the navbar.",
    },
    description: {
      type: "string",
      description: "Used for meta tags and the home page.",
      default: "undefined",
    },
  }}
/>
```

## Więcej komponentów

`InstallBlock` i `CodeBlock` z `onedocs` nie znajdują się w `mdxComponents`. Aby używać ich w MDX, dodaj je do przekazywanego obiektu:

```tsx title="src/app/docs/[[...slug]]/page.tsx"
import { CodeBlock, DocsPage, InstallBlock, mdxComponents } from "onedocs";

// In your page component:
<MDX components={{ ...mdxComponents, InstallBlock, CodeBlock }} />
```

Pozostałe komponenty możesz zaimportować z Fumadocs UI w pliku MDX lub dodać je w ten sam sposób:

```ts
import { Banner } from "fumadocs-ui/components/banner";
import { InlineTOC } from "fumadocs-ui/components/inline-toc";
```

Pełną listę znajdziesz w [dokumentacji Fumadocs](https://fumadocs.dev/docs/ui/components).
