@epubook/theme 0.0.12-beta.1 → 0.0.12-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +3 -3
- package/dist/index.d.mts +0 -15
- package/dist/index.mjs +0 -42
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@epubook/theme",
|
|
3
|
-
"version": "0.0.12-beta.
|
|
3
|
+
"version": "0.0.12-beta.2",
|
|
4
4
|
"description": "Epubook theme",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ebook",
|
|
@@ -34,8 +34,8 @@
|
|
|
34
34
|
"styles"
|
|
35
35
|
],
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"@epubook/core": "0.0.12-beta.
|
|
38
|
-
"@epubook/xml": "0.0.12-beta.
|
|
37
|
+
"@epubook/core": "0.0.12-beta.2",
|
|
38
|
+
"@epubook/xml": "0.0.12-beta.2"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
41
|
"node": ">=v20.10.0"
|
package/dist/index.d.mts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
//#region src/types.d.ts
|
|
2
|
-
type DefaultThemePageTemplate = {
|
|
3
|
-
chapter: PageTemplate<{
|
|
4
|
-
title: string;
|
|
5
|
-
content: string;
|
|
6
|
-
}>;
|
|
7
|
-
};
|
|
8
|
-
//#endregion
|
|
9
|
-
//#region src/chapter.d.ts
|
|
10
|
-
declare const Chapter: DefaultThemePageTemplate['chapter'];
|
|
11
|
-
//#endregion
|
|
12
|
-
//#region src/index.d.ts
|
|
13
|
-
declare function DefaultTheme(): Promise<Theme<DefaultThemePageTemplate>>;
|
|
14
|
-
//#endregion
|
|
15
|
-
export { Chapter, DefaultTheme, DefaultThemePageTemplate };
|
package/dist/index.mjs
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import * as fs from "node:fs";
|
|
2
|
-
import * as path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import { XHTMLBuilder } from "@epubook/core";
|
|
5
|
-
import { Fragment, jsx, jsxs } from "@epubook/xml/jsx-runtime";
|
|
6
|
-
|
|
7
|
-
//#region src/chapter.tsx
|
|
8
|
-
const Chapter = (file, { title, content }) => {
|
|
9
|
-
const lines = content.split(/\r?\n/);
|
|
10
|
-
return new XHTMLBuilder(file).title(title).body(/* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("h2", { children: title }), lines.map((l) => /* @__PURE__ */ jsx("p", { children: l }))] }));
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
//#endregion
|
|
14
|
-
//#region src/index.ts
|
|
15
|
-
const styles = ["./styles/main.css", "./styles/cover.css"];
|
|
16
|
-
async function DefaultTheme() {
|
|
17
|
-
return {
|
|
18
|
-
name: "@epubook/theme-default",
|
|
19
|
-
styles: await Promise.all(styles.map((d) => loadStyle(d))),
|
|
20
|
-
images: [],
|
|
21
|
-
pages: {
|
|
22
|
-
cover(file, { image, title = "封面" }) {
|
|
23
|
-
return new XHTMLBuilder(file).title(title).bodyAttrs({ class: "cover" }).body({
|
|
24
|
-
tag: "img",
|
|
25
|
-
attrs: { src: image.relative(file) }
|
|
26
|
-
});
|
|
27
|
-
},
|
|
28
|
-
nav(file, { nav, option }) {
|
|
29
|
-
if (!option.title) option.title = "目录";
|
|
30
|
-
return new XHTMLBuilder(file).title("目录");
|
|
31
|
-
},
|
|
32
|
-
chapter: Chapter
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
async function loadStyle(dir) {
|
|
37
|
-
const d = path.join(fileURLToPath(import.meta.url), "../../", dir);
|
|
38
|
-
return fs.promises.readFile(d, "utf-8");
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
//#endregion
|
|
42
|
-
export { Chapter, DefaultTheme };
|