generated from arvinxx/npm-template
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
解决 #9 的一个问题
- Loading branch information
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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,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.
6c71f48
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.
Successfully deployed to the following URLs:
dumi-theme-antd-style – ./
dumi-theme-antd-style.vercel.app
dumi-theme-antd-style-git-master-arvinxx.vercel.app
dumi-theme-antd-style.arvinx.app
dumi-theme-antd-style-arvinxx.vercel.app