45 lines
1.1 KiB
Plaintext
45 lines
1.1 KiB
Plaintext
---
|
|
title: GitHub 信息
|
|
description: 显示您的 GitHub 仓库信息
|
|
preview: githubInfo
|
|
---
|
|
|
|
## 使用方法
|
|
|
|
```tsx
|
|
import { GithubInfo } from 'fumadocs-ui/components/github-info';
|
|
|
|
<GithubInfo
|
|
owner="fuma-nama"
|
|
repo="fumadocs"
|
|
// 您自己的 GitHub 访问令牌(可选)
|
|
token={process.env.GITHUB_TOKEN}
|
|
/>;
|
|
```
|
|
|
|
建议将其添加到您的文档布局中,使用 `links` 选项:
|
|
|
|
```tsx title="app/docs/layout.tsx"
|
|
import { DocsLayout, type DocsLayoutProps } from 'fumadocs-ui/layouts/notebook';
|
|
import type { ReactNode } from 'react';
|
|
import { baseOptions } from '@/app/layout.config';
|
|
import { source } from '@/lib/source';
|
|
import { GithubInfo } from 'fumadocs-ui/components/github-info';
|
|
|
|
const docsOptions: DocsLayoutProps = {
|
|
...baseOptions,
|
|
tree: source.pageTree,
|
|
links: [
|
|
{
|
|
type: 'custom',
|
|
children: (
|
|
<GithubInfo owner="fuma-nama" repo="fumadocs" className="lg:-mx-2" />
|
|
),
|
|
},
|
|
],
|
|
};
|
|
|
|
export default function Layout({ children }: { children: ReactNode }) {
|
|
return <DocsLayout {...docsOptions}>{children}</DocsLayout>;
|
|
}
|
|
``` |