Skip to content

Commit

Permalink
📝 docs: 补充自定义 ApiHeader 的说明文档
Browse files Browse the repository at this point in the history
解决 #9 的一个问题
  • Loading branch information
arvinxx committed Mar 13, 2023
1 parent f71432b commit 6c71f48
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions example/docs/config/apiHeader.zh-CN.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
title: ApiHeader
group: 自定义
nav: 配置
---

# 自定义 ApiHeader

在一些业务场景下([issue #9](https://github.com/arvinxx/dumi-theme-antd-style/issues/9#issuecomment-1459116041)),主题包用户可能需要自定义 ApiHeader 中的部分内容。 此时可以通过自定义 slot 来实现。

`.dumi/theme/slots` 目录下创建 `ApiHeader` 文件夹,并添加 `index.tsx` 文件。然后添加以下代码,即可自定义 ApiHeader 的展示:

```tsx | pure
import { SmileOutlined } from '@ant-design/icons';
import { ApiHeader as Header, siteSelectors, useSiteStore } from 'dumi-theme-antdstyle';
import { FC, memo } from 'react';

const ApiHeader: FC = memo(() => {
const props = useSiteStore(siteSelectors.apiHeader);
const { pkg } = props;

const packages = [
{
label: 'icon',
icon: <SmileOutlined />,
children: 'demo',
url: `https://www.npmjs.com/package/${pkg}`,
},
];

return <Header serviceList={packages} {...props} />;
});

export default ApiHeader;
```

关于 ApiHeader 组件的完整配置,请参考 [ApiHeader](/components/api-header) 组件文档。
File renamed without changes.
File renamed without changes.

1 comment on commit 6c71f48

@vercel
Copy link

@vercel vercel bot commented on 6c71f48 Mar 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.