# @asyncapi/html-template 中文文档

规范地址：https://npmcn.com/package/%40asyncapi/html-template/

版本：3\.5\.6
npm 元数据更新时间：2026-07-31T14:02:59.322Z
中文译文更新时间：2026-11-07T01:38:33.085Z
软件包许可：Apache-2\.0

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40asyncapi/html-template
原文对照：https://npmcn.com/package/%40asyncapi/html-template/?lang=original
项目主页：https://github.com/asyncapi/html-template#readme
源码仓库：https://github.com/asyncapi/html-template

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：11 MB，26 个文件
- TypeScript 类型：未声明
- 运行依赖：9 个
- 首次发布：2020-02-08T19:31:22.001Z
- 最新版本发布：2026-03-14T17:04:21.692Z
- 近 30 天下载量：227427（2026-10-07 至 2026-11-05，npm 官方下载统计）
- 已发布版本数：130（近 12 个月 10 个）

## 中文简介

AsyncAPI 生成器的 HTML 模板.

## 安装

```sh
npm install @asyncapi/html-template
```

也可以使用：`pnpm add @asyncapi/html-template`、`yarn add @asyncapi/html-template`、`bun add @asyncapi/html-template`

## README

[![AsyncAPI HTML Template](https://npmcn.com/package/%40asyncapi/html-template/assets/github-repobanner-htmltemp.png)](https://www.asyncapi.com/)

HTML 模板 [AsyncAPI 生成器](https://github.com/asyncapi/generator) 使用一个 [AsyncAPI 反应组件](https://github.com/asyncapi/asyncapi-react) 在引擎盖下.

* * *

[![All Contributors](https://img.shields.io/badge/all_contributors-18-orange.svg?style=flat-square)](https://npmcn.com/package/%40asyncapi/html-template/#readme-contributors-)

![npm](https://img.shields.io/npm/dm/@asyncapi/html-template?style=flat-square)

* * *

-   [使用量](https://npmcn.com/package/%40asyncapi/html-template/#readme-usage)
-   [支持参数](https://npmcn.com/package/%40asyncapi/html-template/#readme-supported-parameters)
-   [发展](https://npmcn.com/package/%40asyncapi/html-template/#readme-development)
-   [贡献者](https://npmcn.com/package/%40asyncapi/html-template/#readme-contributors-%E2%9C%A8)

## 使用量

安装 AsyncAPI CPI

```bash
npm install -g @asyncapi/cli
```

使用 CLI 生成

> 如果您使用 AsyncAPI 生成器 v1 或 v2 模板版本

```bash
asyncapi generate fromTemplate <asyncapi.yaml> @asyncapi/html-template@2.3.14
```

> 如果您使用 AsyncAPI 生成器 v2 的模板版本 v3

```bash
asyncapi generate fromTemplate <asyncapi.yaml> @asyncapi/html-template@3.0.0 --use-new-generator
```

> 如果使用AsyncAPI生成器 v3 和 AsyncAPI CPI v5 的模板版本 v3.5

```bash
asyncapi generate fromTemplate <asyncapi.yaml> @asyncapi/html-template@3.5.0
```

您可以替换 `<asyncapi.yaml>` 本地路径或 URL 指向 [任意 AsyncAPI 文档](https://raw.githubusercontent.com/asyncapi/spec/refs/heads/master/examples/streetlights-kafka-asyncapi.yml)。 。 。 . 调查 [释放](https://npmcn.com/asyncapi/html-template/releases) 的模板,以获取所需的版本。 不建议在生产中总是使用最新产品。 总是使用特定版本.

## 支持参数

| 名称 | 说明 | 需求 | 默认 | 允许的值 | 示例 |
| --- | --- | --- | --- | --- | --- |
| 侧边栏组织 | 定义侧边栏的排列方式。 设定其值为 `byTagsNoRoot` 以操作标记对操作进行分类。 设定其值为 `byTags` 当根位上有标记时。 这些标记用于给标记导航建模,在操作中需要同样的标记. | 没有 | 未定义 | `byTags`, (中文(简体) ), `byTagsNoRoot` | `byTagsNoRoot` |
| 基数Href | 设置链接和窗体的基础 URL. | 没有 | `/` | _任意_ | `/docs` |
| 版本 | 覆盖您的应用程序版本 `info.version` 指定文件中的位置. | 没有 | 版本取自 spec 文件 . | _任意_ (单位:千美元)[见 Semver 版本](https://semver.org/)(中文(简体) ) | `1.0.0` |
| 单文件 | 将输出设置为带有内部样式和脚本的 html 文件 . | 没有 | `false` | `true`, (中文(简体) ),`false` | `true` |
| 外页名 | 输出文件的文件名 . | 没有 | `index.html` | _任意_ | `asyncapi.html` |
| 页:1 | 生成输出 HTML 作为 PDF . | 没有 | `false` | `true`, (中文(简体) ), `false` | `true` |
| pdf 超时 | 超时(以ms为单位)用于生成PDF. | 没有 | 3万块 | 页:1 | 1 000个 |
| 图像 | 定义用于favion 的 URL/ Path . | 没有 | `assets/asyncapi-favicon.ico` | 任何有效的 favicon URL/ Path . | `"https://studio.asyncapi.com/favicon.ico"` |
| 配置 | 内置字符串 JSON 或 JSON 文件路径来覆盖默认的 React 组件配置 。 配置覆盖与默认配置合并使用 [JSON 合并补丁](https://tools.ietf.org/html/rfc7386) 算法. | 没有 | `{ "show": { "sidebar": true }, "sidebar": { "showOperations": "byDefault" } }` | [反应组件的 JSON 配置](https://github.com/asyncapi/asyncapi-react/blob/master/docs/configuration/config-modification.md#definition) | `{"show":{"sidebar":false}}` |

> **页:1**: 如果您只生成 HTML 网站, 请设置环境变量 `PUPPETEER_SKIP_CHROMIUM_DOWNLOAD` 改为 `true` 生成器将跳过下载铬.

## 发展

HTML-Template 以一个 [AsyncAPI 反应组件](https://github.com/asyncapi/asyncapi-react)。关于页面的造型、缺失/已存在的元素的渲染方面的任何改动,请协助 [AsyncAPI 反应组件](https://github.com/asyncapi/asyncapi-react) 仓库.

如果您想要修改模板本身, 请遵循 :

1.  确保您安装了最新的生成器 : `npm install -g @asyncapi/generator`。 。 。 .
    
2.  修改模板或其辅助功能.
    
    > **注:** 如果您需要修改 [`dummy.yml`](https://github.com/asyncapi/generator/blob/master/test/docs/dummy.yml) 文档以开发您的特性, 打开带有更改的 PR [ayncapi/生成器](https://github.com/asyncapi/generator) 仓库.
    
3.  启用监视器生成输出 : `npm run develop`。 。 。 .
    
    > **注:** 如果你的改变不明显,这可能是因为 `ag` 使用已安装的 `html-template` 所以,你应该使用 `--install` 选项
    > 
    > -   运行 `npm run develop:install`
    > -   如果命令失败, 删除缓存 `html-template` 模块并重运行命令
    
4.  在浏览器中打开 HTML : `open ./test/output/index.html`。 。 。 .
    

## 贡献者

感谢这些伟大的人[emoji 密钥](https://allcontributors.org/docs/en/emoji-key):

<table><tbody><tr><td align="center"><a href="https://www.jamescrowley.net/" rel="nofollow noopener noreferrer"><img alt="James Crowley" src="https://avatars1.githubusercontent.com/u/509533?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>詹姆斯·克罗利</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=jamescrowley" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/asyncapi/html-template/issues?q=author%3Ajamescrowley" title="Bug reports" rel="nofollow noopener noreferrer">🐛</a></td><td align="center"><a href="https://waleedashraf.me/" rel="nofollow noopener noreferrer"><img alt="Waleed Ashraf" src="https://avatars0.githubusercontent.com/u/8335457?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>沃尔德·阿什拉夫</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=WaleedAshraf" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/asyncapi/html-template/issues?q=author%3AWaleedAshraf" title="Bug reports" rel="nofollow noopener noreferrer">🐛</a></td><td align="center"><a href="https://deltaeight.de/" rel="nofollow noopener noreferrer"><img alt="Julian Rabe" src="https://avatars1.githubusercontent.com/u/19175262?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>朱利安·拉贝</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=schw4rzlicht" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://github.com/sebastian-palma" rel="nofollow noopener noreferrer"><img alt="Sebastián" src="https://avatars2.githubusercontent.com/u/11888191?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>塞巴斯蒂安省</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=sebastian-palma" title="Tests" rel="nofollow noopener noreferrer">⚠️</a> <a href="https://github.com/asyncapi/html-template/commits?author=sebastian-palma" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://github.com/GordeevArt" rel="nofollow noopener noreferrer"><img alt="Gordeev Artem" src="https://avatars2.githubusercontent.com/u/2003488?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>戈尔德耶夫·阿特姆</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=GordeevArt" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://sa.watz.ky/" rel="nofollow noopener noreferrer"><img alt="Mitchell Sawatzky" src="https://avatars2.githubusercontent.com/u/7246741?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>米切尔·萨瓦茨基</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=bufutda" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://github.com/HashTalmiz" rel="nofollow noopener noreferrer"><img alt="Talmiz Ahmed" src="https://avatars0.githubusercontent.com/u/55018280?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>塔米兹·艾哈迈德</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=HashTalmiz" title="Code" rel="nofollow noopener noreferrer">💻</a></td></tr><tr><td align="center"><a href="https://www.linkedin.com/in/jbreitenbaumer/" rel="nofollow noopener noreferrer"><img alt="Jürgen B." src="https://avatars3.githubusercontent.com/u/683438?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>于尔根 B.</b></sub></a><br><a href="https://npmcn.com/package/%40asyncapi/html-template/#readme-infra-juergenbr" title="Infrastructure (Hosting, Build-Tools, etc)" rel="nofollow noopener noreferrer">🚇</a></td><td align="center"><a href="https://codepen.io/gabrielclaudino/" rel="nofollow noopener noreferrer"><img alt="Gabriel Claudino" src="https://avatars2.githubusercontent.com/u/26636890?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>加布里埃尔·克劳迪诺</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=gabrielclaudino" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://github.com/bszwarc" rel="nofollow noopener noreferrer"><img alt="Barbara Szwarc" src="https://avatars1.githubusercontent.com/u/17266942?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>芭芭拉·斯瓦克</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=bszwarc" title="Documentation" rel="nofollow noopener noreferrer">📖</a></td><td align="center"><a href="https://github.com/Theiaz" rel="nofollow noopener noreferrer"><img alt="Julian S." src="https://avatars.githubusercontent.com/u/9378662?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>(原始内容存档于2018-10-21). Julian S.</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=Theiaz" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="http://blog.ineat-conseil.fr/" rel="nofollow noopener noreferrer"><img alt="Ludovic Dussart" src="https://avatars.githubusercontent.com/u/5501911?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>卢多维奇·杜萨尔</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=M3lkior" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://w3tec.ch/" rel="nofollow noopener noreferrer"><img alt="David Weber" src="https://avatars.githubusercontent.com/u/1021324?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>大卫·韦伯</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=dweber019" title="Code" rel="nofollow noopener noreferrer">💻</a></td><td align="center"><a href="https://github.com/magicmatatjahu" rel="nofollow noopener noreferrer"><img alt="Maciej Urbańczyk" src="https://avatars.githubusercontent.com/u/20404945?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>马西杰·乌尔班奇克</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=magicmatatjahu" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/asyncapi/html-template/commits?author=magicmatatjahu" title="Tests" rel="nofollow noopener noreferrer">⚠️</a> <a href="https://github.com/asyncapi/html-template/issues?q=author%3Amagicmatatjahu" title="Bug reports" rel="nofollow noopener noreferrer">🐛</a> <a href="https://npmcn.com/package/%40asyncapi/html-template/#readme-maintenance-magicmatatjahu" title="Maintenance" rel="nofollow noopener noreferrer">🚧</a> <a href="https://github.com/asyncapi/html-template/pulls?q=is%3Apr+reviewed-by%3Amagicmatatjahu" title="Reviewed Pull Requests" rel="nofollow noopener noreferrer">👀</a></td></tr><tr><td align="center"><a href="https://www.brainfart.dev/" rel="nofollow noopener noreferrer"><img alt="Lukasz Gornicki" src="https://avatars.githubusercontent.com/u/6995927?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>卢卡斯·戈尔尼茨基</b></sub></a><br><a href="https://npmcn.com/package/%40asyncapi/html-template/#readme-maintenance-derberg" title="Maintenance" rel="nofollow noopener noreferrer">🚧</a> <a href="https://github.com/asyncapi/html-template/commits?author=derberg" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/asyncapi/html-template/issues?q=author%3Aderberg" title="Bug reports" rel="nofollow noopener noreferrer">🐛</a> <a href="https://github.com/asyncapi/html-template/pulls?q=is%3Apr+reviewed-by%3Aderberg" title="Reviewed Pull Requests" rel="nofollow noopener noreferrer">👀</a> <a href="https://github.com/asyncapi/html-template/commits?author=derberg" title="Tests" rel="nofollow noopener noreferrer">⚠️</a></td><td align="center"><a href="http://www.fmvilas.com/" rel="nofollow noopener noreferrer"><img alt="Fran Méndez" src="https://avatars.githubusercontent.com/u/242119?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>弗朗·门德斯</b></sub></a><br><a href="https://npmcn.com/package/%40asyncapi/html-template/#readme-maintenance-fmvilas" title="Maintenance" rel="nofollow noopener noreferrer">🚧</a> <a href="https://github.com/asyncapi/html-template/commits?author=fmvilas" title="Code" rel="nofollow noopener noreferrer">💻</a> <a href="https://github.com/asyncapi/html-template/issues?q=author%3Afmvilas" title="Bug reports" rel="nofollow noopener noreferrer">🐛</a> <a href="https://github.com/asyncapi/html-template/pulls?q=is%3Apr+reviewed-by%3Afmvilas" title="Reviewed Pull Requests" rel="nofollow noopener noreferrer">👀</a> <a href="https://github.com/asyncapi/html-template/commits?author=fmvilas" title="Tests" rel="nofollow noopener noreferrer">⚠️</a></td><td align="center"><a href="https://github.com/Arya-Gupta" rel="nofollow noopener noreferrer"><img alt="Arya Gupta" src="https://avatars.githubusercontent.com/u/84087089?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>阿里亚·古普塔</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=Arya-Gupta" title="Documentation" rel="nofollow noopener noreferrer">📖</a></td><td align="center"><a href="https://github.com/neoandmatrix" rel="nofollow noopener noreferrer"><img alt="Tushar" src="https://avatars.githubusercontent.com/u/141230066?v=4?s=100" width="100px;" loading="lazy" decoding="async" referrerpolicy="no-referrer"><br><sub><b>图沙尔</b></sub></a><br><a href="https://github.com/asyncapi/html-template/commits?author=neoandmatrix" title="Code" rel="nofollow noopener noreferrer">💻</a></td></tr></tbody></table>

本项目遵循 [全部贡献者](https://github.com/all-contributors/all-contributors) 规格。 任何捐款都欢迎!

## 常见问题

### @asyncapi/html-template 是什么？

AsyncAPI 生成器的 HTML 模板\.

### 如何安装 @asyncapi/html-template？

在项目目录运行 npm install @asyncapi/html-template，或使用 pnpm add / yarn add / bun add。

### @asyncapi/html-template 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/asyncapi\_\_html-template 是否存在。

### @asyncapi/html-template 可以商用吗？

@asyncapi/html-template 使用 Apache-2\.0 许可。宽松许可：允许商业使用、修改和再分发，并附带明确的专利授权；分发时需保留许可与 NOTICE 文件，修改过的文件要注明改动。以上为概括，不构成法律意见，请以许可原文为准。

### @asyncapi/html-template 的下载量有多少？

根据 npm 官方下载统计，@asyncapi/html-template 在 2026/10/07 – 2026/11/05 这 30 天内被下载 227,427 次，日均约 7,581 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @asyncapi/html-template 还在维护吗？

最新版本 3\.5\.6 发布于 2026/03/15（7 个月前）；至今共发布 130 个版本，其中过去 12 个月发布了 10 个；首次发布于 2020/02/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

