@berlysia/vertical-writing-slide-system 0.0.4 → 0.0.6
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/cli.js +4 -1
- package/index.html +19 -0
- package/package.json +6 -5
- package/scripts/build-pages.js +34 -35
package/cli.js
CHANGED
|
@@ -25,7 +25,10 @@ async function runBuildAll() {
|
|
|
25
25
|
|
|
26
26
|
async function runBuild() {
|
|
27
27
|
try {
|
|
28
|
-
|
|
28
|
+
await build({
|
|
29
|
+
root: import.meta.dirname,
|
|
30
|
+
configFile: "vite.config.ts",
|
|
31
|
+
});
|
|
29
32
|
} catch (error) {
|
|
30
33
|
console.error("Error during build:", error);
|
|
31
34
|
process.exit(1);
|
package/index.html
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html lang="ja">
|
|
3
|
+
<head>
|
|
4
|
+
<meta charset="UTF-8" />
|
|
5
|
+
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
|
|
6
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
|
+
<title>Vite + React + TS</title>
|
|
8
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
9
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
10
|
+
<link href="https://fonts.googleapis.com/css2?family=Noto+Sans+JP&family=Noto+Sans+Mono:wght@100..900&display=swap" rel="stylesheet">
|
|
11
|
+
<link rel="stylesheet" href="/src/index.css" />
|
|
12
|
+
<link rel="stylesheet" media="screen" href="/src/screen.css" />
|
|
13
|
+
<link rel="stylesheet" media="print" href="/src/print.css" />
|
|
14
|
+
</head>
|
|
15
|
+
<body>
|
|
16
|
+
<div id="root"></div>
|
|
17
|
+
<script type="module" src="/src/main.tsx"></script>
|
|
18
|
+
</body>
|
|
19
|
+
</html>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@berlysia/vertical-writing-slide-system",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.6",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"bin": {
|
|
6
6
|
"vertical-slides": "./cli.js"
|
|
@@ -12,7 +12,8 @@
|
|
|
12
12
|
"tsconfig.*.json",
|
|
13
13
|
"cli.js",
|
|
14
14
|
"scripts/build-pages.js",
|
|
15
|
-
"src"
|
|
15
|
+
"src",
|
|
16
|
+
"index.html"
|
|
16
17
|
],
|
|
17
18
|
"dependencies": {
|
|
18
19
|
"@emotion/react": "^11.14.0",
|
|
@@ -26,7 +27,8 @@
|
|
|
26
27
|
"remark-rehype": "^11.1.1",
|
|
27
28
|
"tsx": "^4.19.3",
|
|
28
29
|
"unified": "^11.0.5",
|
|
29
|
-
"vfile": "^6.0.3"
|
|
30
|
+
"vfile": "^6.0.3",
|
|
31
|
+
"vite": "^6.2.1"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
32
34
|
"@eslint/js": "^9.21.0",
|
|
@@ -49,8 +51,7 @@
|
|
|
49
51
|
"prompts": "^2.4.2",
|
|
50
52
|
"typescript": "~5.8.2",
|
|
51
53
|
"typescript-eslint": "^8.26.0",
|
|
52
|
-
"unist-util-visit": "^5.0.0"
|
|
53
|
-
"vite": "^6.2.1"
|
|
54
|
+
"unist-util-visit": "^5.0.0"
|
|
54
55
|
},
|
|
55
56
|
"scripts": {
|
|
56
57
|
"dev": "vite",
|
package/scripts/build-pages.js
CHANGED
|
@@ -1,24 +1,27 @@
|
|
|
1
|
-
import { execSync } from "child_process";
|
|
2
1
|
import { existsSync } from "fs";
|
|
3
2
|
import { mkdir, readdir, stat, cp, writeFile } from "fs/promises";
|
|
4
3
|
import { join, resolve } from "path";
|
|
4
|
+
import { build } from "vite";
|
|
5
5
|
const defaultSlidesDir = resolve(import.meta.dirname, "..", "slides");
|
|
6
6
|
const pagesDir = "pages";
|
|
7
7
|
// Ensure pages directory exists
|
|
8
8
|
await mkdir(pagesDir, { recursive: true });
|
|
9
9
|
async function buildSlide(slideName) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
10
|
+
console.log(`Building ${slideName}...`);
|
|
11
|
+
process.env.SLIDE_NAME = slideName;
|
|
12
|
+
await build({
|
|
13
|
+
root: resolve(import.meta.dirname, ".."),
|
|
14
|
+
configFile: "vite.config.ts",
|
|
15
|
+
});
|
|
16
|
+
const slideOutputDir = join(pagesDir, slideName);
|
|
17
|
+
await mkdir(slideOutputDir, { recursive: true });
|
|
18
|
+
await cp("dist", slideOutputDir, { recursive: true });
|
|
16
19
|
}
|
|
17
20
|
async function createIndexPage(slideNames) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
21
|
+
const slides = slideNames
|
|
22
|
+
.map((name) => ` <li><a href="${name}/">${name}</a></li>`)
|
|
23
|
+
.join("\n");
|
|
24
|
+
const html = `<!DOCTYPE html>
|
|
22
25
|
<html>
|
|
23
26
|
<head>
|
|
24
27
|
<meta charset="UTF-8">
|
|
@@ -31,33 +34,29 @@ ${slides}
|
|
|
31
34
|
</ul>
|
|
32
35
|
</body>
|
|
33
36
|
</html>`;
|
|
34
|
-
|
|
37
|
+
await writeFile(join(pagesDir, "index.html"), html);
|
|
35
38
|
}
|
|
36
39
|
export async function buildPages(options = {}) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
slideNames.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
for (const slide of slides) {
|
|
53
|
-
await buildSlide(slide);
|
|
54
|
-
}
|
|
55
|
-
await createIndexPage(slides);
|
|
40
|
+
const resolvedSlidesDir = options.slidesDir ?? defaultSlidesDir;
|
|
41
|
+
// Build all slides
|
|
42
|
+
if (!existsSync(resolvedSlidesDir)) {
|
|
43
|
+
throw new Error(`Slides directory not found (tried: ${resolvedSlidesDir})`);
|
|
44
|
+
}
|
|
45
|
+
const slideNames = await readdir(resolvedSlidesDir);
|
|
46
|
+
const slideStats = await Promise.all(slideNames.map((item) => stat(join(resolvedSlidesDir, item))));
|
|
47
|
+
const slides = slideNames.filter((_, index) => slideStats[index].isDirectory());
|
|
48
|
+
if (slides.length === 0) {
|
|
49
|
+
throw new Error("No slides found");
|
|
50
|
+
}
|
|
51
|
+
for (const slide of slides) {
|
|
52
|
+
await buildSlide(slide);
|
|
53
|
+
}
|
|
54
|
+
await createIndexPage(slides);
|
|
56
55
|
}
|
|
57
56
|
// CLI entry point
|
|
58
57
|
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
58
|
+
buildPages({ slidesDir: process.env.SLIDES_DIR }).catch((error) => {
|
|
59
|
+
console.error(error);
|
|
60
|
+
process.exit(1);
|
|
61
|
+
});
|
|
63
62
|
}
|