-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
90 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,5 @@ | ||
export * from './epub'; | ||
|
||
export * from './error'; | ||
|
||
export * from './theme'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export interface Theme { | ||
name: string; | ||
|
||
pages: string[]; | ||
|
||
styles: string[]; | ||
|
||
images: string[]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import { type Author, type Theme, Epub } from '@epubook/core'; | ||
|
||
import { loadTheme } from './theme'; | ||
|
||
export interface EpubookOption { | ||
title: string; | ||
|
||
language: string; | ||
|
||
author: Author[]; | ||
|
||
theme: string; | ||
} | ||
|
||
export class Epubook { | ||
private container: Epub; | ||
|
||
private option: EpubookOption; | ||
|
||
private theme!: Theme; | ||
|
||
private constructor(option: Partial<EpubookOption>) { | ||
this.option = { | ||
title: '', | ||
language: 'zh-CN', | ||
author: [{ name: 'unknown' }], | ||
theme: '@epubook/theme-default', | ||
...option | ||
}; | ||
|
||
this.container = new Epub(this.option); | ||
} | ||
|
||
public static async create(option: Partial<EpubookOption>) { | ||
const epubook = new Epubook(option); | ||
return await epubook.loadTheme(); | ||
} | ||
|
||
private async loadTheme() { | ||
await loadTheme(this.option.theme); | ||
return this; | ||
} | ||
|
||
public epub() { | ||
return this.container; | ||
} | ||
|
||
public setCover() { | ||
return this; | ||
} | ||
|
||
public addPage() { | ||
return this; | ||
} | ||
|
||
public setToc() { | ||
return this; | ||
} | ||
|
||
public setSpine() { | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export async function loadTheme(pkg: string) {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,7 @@ | |
"pages": [], | ||
"styles": [ | ||
"styles/main.css" | ||
] | ||
], | ||
"images": [] | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters