0.0.11 • Published 2 years ago

@epubook/core v0.0.11

Weekly downloads
-
License
MIT
Repository
github
Last release
2 years 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

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago