0.0.11 • Published 8 months ago

@epubook/core v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

@epubook/core

version CI

The fundamental module of epubook. It provides low-level API for generating EPUB books.

Installation

npm i @epubook/core

Usage

import { Epub, HTML } from '@epubook/core'

const book = new Epub({
  title: 'Test Book',
  date: new Date('2023-02-01T11:00:00.000Z'),
  lastModified: new Date('2023-02-26T11:00:00.000Z'),
  creator: 'XLor',
  description: 'for test usage',
  source: 'imagine'
})

const page = new HTML('start.xhtml', '...')

book.item(page).spine(page).toc([{ title: 'Start', page }])

await book.writeFile('./test.epub')

JSX

You can use jsx to create XHTML node.

// Your theme code ...

import { XHTMLBuilder } from '@epubook/core'

const builder = new XHTMLBuilder()

builder
  .body(<h1>Title</h1>)
  .body(<p>This is a paragraph</p>)
  .build()

Currently, it supports use unbuild to transform JSX / TSX and bundle your library.

// build.config.ts

import { defineBuildConfig } from 'unbuild';

import { UnbuildPreset } from '@epubook/core';

export default defineBuildConfig({
  entries: ['src/index'],
  declaration: true,
  clean: true,
  rollup: {
    emitCJS: true
  },
  preset: UnbuildPreset()
});

You can see @epubook/theme-default for more details.

License

MIT License © 2023 XLor

0.0.11

8 months ago

0.0.10

1 year ago

0.0.9

1 year ago

0.0.8

1 year ago

0.0.7

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago