diff --git a/packages/epubook/src/epubook.ts b/packages/epubook/src/epubook.ts index a71bbc5..3d7eed6 100644 --- a/packages/epubook/src/epubook.ts +++ b/packages/epubook/src/epubook.ts @@ -1,7 +1,12 @@ -import { NavList, NavOption } from './../../core/src/epub/nav'; +import * as path from 'node:path'; + +import type { DefaultTheme, DefaultThemePageTemplate } from '@epubook/theme-default'; + import { type Theme, type Author, + type NavList, + type NavOption, type PageTemplate, type ImageExtension, type ImageMediaType, @@ -13,14 +18,11 @@ import { Style } from '@epubook/core'; -import type { DefaultTheme, DefaultThemePageTemplate } from '@epubook/theme-default'; - -import * as path from 'node:path'; - import { Cover } from './pages'; import { EpubookError } from './error'; -export interface EpubookOption = Awaited>> { +export interface EpubookOption = Awaited>> + extends PackageDocumentMeta { title: string; description: string; @@ -38,7 +40,7 @@ const ImageDir = 'images'; export class Epubook

= DefaultThemePageTemplate> { private theme!: Theme

; - private _option: Omit>, 'theme'>; + private _option: Partial>, 'theme'>>; private _container: Epub; @@ -63,7 +65,11 @@ export class Epubook

= DefaultThemePageTe ...option }; - this._container = new Epub(this._option); + this._container = new Epub({ + creator: this._option.author![0], + contributor: this._option.author!.slice(1), + ...this._option + }); } public static async create

= DefaultThemePageTemplate>( @@ -179,7 +185,7 @@ export class Epubook

= DefaultThemePageTe } return render(file, props) .style(...this._styles) - .language(this._option.language); + .language(this._option.language ?? 'zh-CN'); } public page['pages']>( diff --git a/packages/epubook/test/index.test.ts b/packages/epubook/test/index.test.ts index b41ce24..f798433 100644 --- a/packages/epubook/test/index.test.ts +++ b/packages/epubook/test/index.test.ts @@ -5,9 +5,14 @@ import { Epubook } from '../src'; describe('epubook', () => { it('should write epub with cover', async () => { const book = await Epubook.create({ - title: 'cover', + title: 'epubook test', description: 'This is generated for testing cover image', - language: 'zh-CN' + language: 'zh-CN', + author: [{ name: 'XLor', fileAs: 'xlor' }], + date: new Date('2023-02-28'), + lastModified: new Date('2023-03-05'), + subject: 'novel', + publisher: 'XLor Books' }); const cover = await book.cover('../../assets/cover.jpg');