From 6c71f4813d81aedeeb573c64ac1709bc2521f245 Mon Sep 17 00:00:00 2001 From: arvinxx Date: Tue, 14 Mar 2023 00:44:46 +0800 Subject: [PATCH] =?UTF-8?q?:memo:=20docs:=20=E8=A1=A5=E5=85=85=E8=87=AA?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=20ApiHeader=20=E7=9A=84=E8=AF=B4=E6=98=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 解决 #9 的一个问题 --- example/docs/config/apiHeader.zh-CN.md | 37 +++++++++++++++++++ .../index.en-US.md} | 0 .../index.zh-CN.md} | 0 3 files changed, 37 insertions(+) create mode 100644 example/docs/config/apiHeader.zh-CN.md rename example/docs/{config.en-US.md => config/index.en-US.md} (100%) rename example/docs/{config.zh-CN.md => config/index.zh-CN.md} (100%) diff --git a/example/docs/config/apiHeader.zh-CN.md b/example/docs/config/apiHeader.zh-CN.md new file mode 100644 index 0000000..9ce65ab --- /dev/null +++ b/example/docs/config/apiHeader.zh-CN.md @@ -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: , + children: 'demo', + url: `https://www.npmjs.com/package/${pkg}`, + }, + ]; + + return
; +}); + +export default ApiHeader; +``` + +关于 ApiHeader 组件的完整配置,请参考 [ApiHeader](/components/api-header) 组件文档。 diff --git a/example/docs/config.en-US.md b/example/docs/config/index.en-US.md similarity index 100% rename from example/docs/config.en-US.md rename to example/docs/config/index.en-US.md diff --git a/example/docs/config.zh-CN.md b/example/docs/config/index.zh-CN.md similarity index 100% rename from example/docs/config.zh-CN.md rename to example/docs/config/index.zh-CN.md