# bookcover-core 中文文档

规范地址：https://npmcn.com/package/bookcover-core/

版本：0\.24\.0
npm 元数据更新时间：2026-11-03T04:34:20.750Z
中文译文更新时间：2026-11-03T06:04:11.942Z
软件包许可：MIT-0

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

原始 npm 页面：https://www.npmjs.com/package/bookcover-core
原文对照：https://npmcn.com/package/bookcover-core/?lang=original
项目主页：https://github.com/gracious-tech/bookcover/tree/main/generator#readme
源码仓库：https://github.com/gracious-tech/bookcover

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

- 包体积（解压后）：2.7 MB，188 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：10 个
- 首次发布：2026-07-16T11:56:20.645Z
- 最新版本发布：2026-11-03T04:34:20.054Z
- 已发布版本数：28（近 12 个月 28 个）

## 中文简介

部分 [封套](https://github.com/gracious-tech/bookcover) 一代系统。

## 安装

```sh
npm install bookcover-core
```

也可以使用：`pnpm add bookcover-core`、`yarn add bookcover-core`、`bun add bookcover-core`

## README

# 书封面-核心-模式参考

部分 [封套](https://github.com/gracious-tech/bookcover) 一代系统。

这是核心生成器包-不直接使用。安装 [bookcover-node](https://www.npmjs.com/package/bookcover-node) 为Node.js或 [bookcover-web](https://www.npmjs.com/package/bookcover-web) 对于浏览器。 本文档描述了两者接受的模式。

所有颜色必须是HSL字符串的格式 `hsl(200deg, 50%, 30%)`.

## 打印/尺寸

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `service_id` | `string` | 印刷服务: `kdp`， `lulu`， `officeworks`， `vistaprint_au`， `ctrlprint` |
| `binding_type` | `string` | 如。 `paperback`， `hardcover` -视乎服务而定 |
| `size_id` | `string?` | 如。 `us_trade`， `a5` -省略如果使用自定义尺寸 |
| `page_count` | `number?` | 使用时需要 `size_id` |
| `ink_type` | `string?` | 如。 `bw`， `color` -某些服务需要 |
| `paper_type` | `string?` | 如。 `white`， `cream` -某些服务需要 |
| `custom_unit` | `string?` | `mm` 或者 `in` -用于自定义尺寸 |
| `custom_trim_width` | `number?` | 内剪宽度 `custom_unit` |
| `custom_trim_height` | `number?` | 纵倾高度 `custom_unit` |
| `custom_bleed` | `number?` | 流血的 `custom_unit` |
| `custom_spine` | `number?` | 脊宽 `custom_unit` |
| `margin_front` | `number?` | 前面板文本边距为装饰高度的% |
| `margin_back` | `number?` | 后面板文本边距为装饰高度的% |

## 标题

三个标题行(`title1`， `title2`， `title3`)每个人都有相同的一组选项。 `title1` 是主标题。

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `title1` | `string` | 主标题（默认） `''`） |
| `title1_font` | `{family: string}?` | 在Typst中使用的字体族名称 |
| `title1_size` | `number?` | 相对大小乘数（默认1.0） |
| `title1_weight` | `number?` | css样式的权重100-900（默认为700） |
| `title1_italic` | `boolean?` |  |
| `title1_color` | `hsl?` | 默认为对比色vs `bg_color` |
| `title_alignment` | `center|left|right?` |  |
| `title_position` | `top|middle|bottom` | 要求 |
| `title_spacing` | `number?` | 标题行之间的间距占装饰高度的% |
| `title_margin_top` | `number?` | 上边距为装饰高度的% |
| `title_margin_bottom` | `number?` | 底部边距为装饰高度的% |

`title2` 和 `title3` 拥有相同的 `_font`， `_size`， `_weight`， `_italic`， `_color` 字段; `title2`/`title3` 颜色默认为 `title1_color`.

## 副标题

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `subtitle` | `string` | (默认 `''`） |
| `subtitle_font` | `{family: string}?` |  |
| `subtitle_size` | `number?` |  |
| `subtitle_weight` | `number?` | 100 - 900 |
| `subtitle_italic` | `boolean?` |  |
| `subtitle_color` | `hsl?` |  |
| `subtitle_alignment` | `center|left|right?` |  |
| `subtitle_position` | `top|middle|bottom` | 要求 |
| `subtitle_spacing` | `number?` | 副标题行之间的间距占裁边高度的% |
| `subtitle_margin_top` | `number?` |  |
| `subtitle_margin_bottom` | `number?` |  |

## 作者

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `author` | `string` | (默认 `''`） |
| `author_font` | `{family: string}?` |  |
| `author_size` | `number?` |  |
| `author_weight` | `number?` | 100 - 900 |
| `author_italic` | `boolean?` |  |
| `author_color` | `hsl?` |  |
| `author_alignment` | `center|left|right?` |  |
| `author_position` | `top|middle|bottom` | 要求 |
| `author_margin_top` | `number?` |  |
| `author_margin_bottom` | `number?` |  |

## 简介（后面板）

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `blurb` | `string` | 封底文字（默认） `''`） |
| `blurb_font` | `{family: string}?` |  |
| `blurb_size` | `number?` |  |
| `blurb_color` | `hsl?` |  |
| `blurb_bg_color` | `hsl|null?` | `undefined` 源自于 `bg_color`； `null` =透明 |
| `blurb_alignment` | `center|left|right|justified?` |  |
| `blurb_padding` | `number?` | 填充为装饰高度的% |
| `blurb_width` | `number?` | 宽度为面宽的% |
| `blurb_spacing` | `number?` | 行间距倍增器（1 =默认Typst前导） |

## 脊柱

如果没有设置，脊柱文本默认为前标题和作者。通过 `''` 显式地 压制书脊文字。

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `spine_title` | `string?` | 省略派生自 `title1`； `''` 抑制 |
| `spine_title_font` | `{family: string}?` |  |
| `spine_title_size` | `number?` |  |
| `spine_title_weight` | `number?` |  |
| `spine_title_italic` | `boolean?` |  |
| `spine_title_color` | `hsl?` |  |
| `spine_author` | `string?` | 省略派生自 `author`； `''` 抑制 |
| `spine_author_font` | `{family: string}?` |  |
| `spine_author_size` | `number?` |  |
| `spine_author_weight` | `number?` |  |
| `spine_author_italic` | `boolean?` |  |
| `spine_author_color` | `hsl?` |  |
| `spine_color` | `hsl|null?` | `null` =没有单独的spine颜色（使用primary bg） |

## 背景

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `bg_color` | `hsl?` | 原色背景色 |
| `bg_color_gradient` | `boolean?` | 背景渐变 |
| `bg_image_coverage` | `full|front|painted|feature|front_partial?` | 背景图像是如何放置的 |
| `icon_id` | `string?` | 图标化ID(例如： `game-icons:sailboat`)或原始SVG |
| `icon_mode` | `center|offset|echo|background?` |  |
| `icon_size` | `number?` | 相对大小倍增器，范围0.25-4 |
| `icon_color` | `string?` |  |
| `icon_spine` | `boolean?` | 显示脊柱上的图标 |
| `pattern` | `string?` | 原始SVG字符串平铺作为背景图案 |
| `pattern_tile_mm` | `number?` | 图案瓦片大小（mm）（默认80） |
| `pattern_color` | `string?` |  |

## 其他

| 场 | 类型 | 笔记 |
| --- | --- | --- |
| `isbn` | `string` | ISBN-13;在封底上生成条形码（默认） `''`） |

## 常见问题

### bookcover-core 是什么？

部分 封套 一代系统。

### 如何安装 bookcover-core？

在项目目录运行 npm install bookcover-core，或使用 pnpm add / yarn add / bun add。

### bookcover-core 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### bookcover-core 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### bookcover-core 可以商用吗？

bookcover-core 使用 MIT-0 许可。声明的许可为 MIT-0，请阅读许可原文确认使用条件。以上为概括，不构成法律意见，请以许可原文为准。

### bookcover-core 还在维护吗？

最新版本 0\.24\.0 发布于 2026/11/03（今天）；至今共发布 28 个版本，其中过去 12 个月发布了 28 个；首次发布于 2026/07/16。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

