slidev-workspace 0.6.0 → 0.6.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/dist/cli.js CHANGED
@@ -15,7 +15,7 @@ import { spawn } from "child_process";
15
15
  //#region src/scripts/config.ts
16
16
  const DEFAULT_CONFIG = {
17
17
  slidesDir: ["./slides"],
18
- outputDir: "./dist",
18
+ outputDir: "./_gh-pages",
19
19
  baseUrl: "/",
20
20
  exclude: ["node_modules", ".git"],
21
21
  hero: {
@@ -405,31 +405,26 @@ async function exportOgImages() {
405
405
  process.exit(1);
406
406
  }
407
407
  }
408
- async function copyToGhPages() {
408
+ async function copySlidesToOutputDir() {
409
409
  const workspaceCwd = process.env.SLIDEV_WORKSPACE_CWD || process.cwd();
410
410
  const config = loadConfig(workspaceCwd);
411
411
  const slidesDirs = resolveSlidesDirs(config, workspaceCwd);
412
- const ghPagesDir = join(workspaceCwd, "_gh-pages");
413
- console.log("📁 Copying files to _gh-pages directory...");
414
- if (!existsSync(ghPagesDir)) mkdirSync(ghPagesDir, { recursive: true });
412
+ const deployDir = resolve(workspaceCwd, config.outputDir);
413
+ console.log(`📁 Copying slide builds into ${deployDir}...`);
414
+ if (!existsSync(deployDir)) mkdirSync(deployDir, { recursive: true });
415
415
  for (const slidesDir of slidesDirs) {
416
416
  if (!existsSync(slidesDir)) continue;
417
417
  const slides = readdirSync(slidesDir, { withFileTypes: true }).filter((dirent) => dirent.isDirectory()).map((dirent) => dirent.name);
418
418
  for (const slideName of slides) {
419
419
  const slideDistDir = join(slidesDir, slideName, "dist");
420
- const targetDir = join(ghPagesDir, slideName);
420
+ const targetDir = join(deployDir, slideName);
421
421
  if (existsSync(slideDistDir)) {
422
- console.log(`📋 Copying ${slideName} to _gh-pages...`);
422
+ console.log(`📋 Copying ${slideName}...`);
423
423
  await cp(slideDistDir, targetDir, { recursive: true });
424
424
  }
425
425
  }
426
426
  }
427
- const previewDistDir = join(workspaceCwd, config.outputDir);
428
- if (existsSync(previewDistDir)) {
429
- console.log("📋 Copying preview app as index...");
430
- await cp(previewDistDir, ghPagesDir, { recursive: true });
431
- }
432
- console.log("✅ All files copied to _gh-pages successfully!");
427
+ console.log(`✅ All slide assets copied into ${deployDir}!`);
433
428
  }
434
429
  async function runViteBuild() {
435
430
  try {
@@ -437,7 +432,7 @@ async function runViteBuild() {
437
432
  console.log("📦 Building Slidev Workspace for production...");
438
433
  const config = createViteConfig();
439
434
  await build(config);
440
- await copyToGhPages();
435
+ await copySlidesToOutputDir();
441
436
  console.log("✅ Build completed successfully!");
442
437
  } catch (error) {
443
438
  console.error("❌ Build failed:", error);
package/dist/index.d.ts CHANGED
@@ -55,14 +55,24 @@ declare function useSlides(): {
55
55
  //#endregion
56
56
  //#region src/types/config.d.ts
57
57
  interface HeroConfig {
58
+ /** Main heading displayed at the top of the workspace page. */
58
59
  title: string;
60
+ /** Supporting copy shown under the hero title. */
59
61
  description: string;
60
62
  }
63
+ /**
64
+ * Slidev Workspace configuration loaded from slidev-workspace.yaml.
65
+ */
61
66
  interface SlidevWorkspaceConfig {
67
+ /** One or more directories that contain slide packages. */
62
68
  slidesDir: string[];
69
+ /** Where the aggregated preview app should output its build. */
63
70
  outputDir: string;
71
+ /** Public base URL used when serving or building slides. */
64
72
  baseUrl: string;
73
+ /** Folder names to ignore when scanning for slides. */
65
74
  exclude: string[];
75
+ /** Hero content surfaced by the preview application. */
66
76
  hero: HeroConfig;
67
77
  }
68
78
  //#endregion
package/dist/index.js CHANGED
@@ -64,7 +64,7 @@ function resolveImageUrl(slide, domain) {
64
64
  if (hasOgImage) {
65
65
  const imagePath = `og-image.png?v=${Date.now()}`;
66
66
  try {
67
- const path = IS_DEVELOPMENT ? pathJoin(slidePath, imagePath) : pathJoin(baseUrl, slidePath, imagePath);
67
+ const path = IS_DEVELOPMENT ? imagePath : pathJoin(baseUrl, slidePath, imagePath);
68
68
  return new URL(path, domain).href;
69
69
  } catch (error) {
70
70
  console.error("Failed to resolve og-image.png path:", error);
@@ -83,7 +83,7 @@ function resolveImageUrl(slide, domain) {
83
83
  if (background) {
84
84
  if (isUrl(background)) return background;
85
85
  try {
86
- return IS_DEVELOPMENT ? new URL(pathJoin(slidePath, background), domain).href : new URL(pathJoin(baseUrl, slidePath, background), domain).href;
86
+ return IS_DEVELOPMENT ? new URL(background, domain).href : new URL(pathJoin(baseUrl, slidePath, background), domain).href;
87
87
  } catch (error) {
88
88
  console.error("Failed to resolve background path:", error);
89
89
  return "https://cover.sli.dev";
@@ -6,7 +6,7 @@ import { spawn } from "child_process";
6
6
  //#region src/scripts/config.ts
7
7
  const DEFAULT_CONFIG = {
8
8
  slidesDir: ["./slides"],
9
- outputDir: "./dist",
9
+ outputDir: "./_gh-pages",
10
10
  baseUrl: "/",
11
11
  exclude: ["node_modules", ".git"],
12
12
  hero: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slidev-workspace",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "description": "A workspace tool for managing multiple Slidev presentations with API-based content management",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -45,7 +45,7 @@ describe("resolveImageUrl (Development Mode)", () => {
45
45
 
46
46
  const result = resolveImageUrl(slide, domain);
47
47
 
48
- expect(result).toBe("http://localhost:3001/og-image.png");
48
+ expect(result).toMatch(/^http:\/\/localhost:3001\/og-image\.png\?v=\d+$/);
49
49
  });
50
50
 
51
51
  it("should return seoMeta.ogImage when it's an absolute URL", async () => {
@@ -115,9 +115,7 @@ describe("resolveImageUrl (Development Mode)", () => {
115
115
 
116
116
  const result = resolveImageUrl(slide, domain);
117
117
 
118
- expect(result).toBe(
119
- "http://localhost:3001/slides-presentation-1/background.jpg",
120
- );
118
+ expect(result).toBe("http://localhost:3001/background.jpg");
121
119
  });
122
120
 
123
121
  it("should return default cover when no image sources provided", async () => {
@@ -150,7 +148,7 @@ describe("resolveImageUrl (Development Mode)", () => {
150
148
 
151
149
  const result = resolveImageUrl(slide, domain);
152
150
 
153
- expect(result).toBe("http://localhost:3001/og-image.png");
151
+ expect(result).toMatch(/^http:\/\/localhost:3001\/og-image\.png\?v=\d+$/);
154
152
  expect(result).not.toBe("https://example.com/image.jpg");
155
153
  });
156
154
 
@@ -217,13 +215,14 @@ describe("resolveImageUrl (Production Mode)", () => {
217
215
  const slide = createMockSlide({
218
216
  hasOgImage: true,
219
217
  baseUrl: "/slidev-workspace-starter",
218
+ path: "/slides-presentation-1/",
220
219
  });
221
220
  const domain = "https://my-slides.com";
222
221
 
223
222
  const result = resolveImageUrl(slide, domain);
224
223
 
225
- expect(result).toBe(
226
- "https://my-slides.com/slidev-workspace-starter/og-image.png",
224
+ expect(result).toMatch(
225
+ /^https:\/\/my-slides\.com\/slidev-workspace-starter\/slides-presentation-1\/og-image\.png\?v=\d+$/,
227
226
  );
228
227
  });
229
228
 
@@ -443,7 +442,9 @@ describe("useSlides (Development Mode)", () => {
443
442
 
444
443
  const firstSlide = slides.value[0];
445
444
 
446
- expect(firstSlide.image).toBe("http://localhost:3001/og-image.png");
445
+ expect(firstSlide.image).toMatch(
446
+ /^http:\/\/localhost:3001\/og-image\.png\?v=\d+$/,
447
+ );
447
448
  });
448
449
 
449
450
  it("should use default cover when no background is provided", async () => {
@@ -540,8 +541,8 @@ describe("useSlides (Production Mode)", () => {
540
541
  const result = await setupUseSlidesProduction();
541
542
  const firstSlide = result.slides.value[0];
542
543
 
543
- expect(firstSlide.image).toBe(
544
- "https://my-slides.com/slidev-workspace-starter/og-image.png",
544
+ expect(firstSlide.image).toMatch(
545
+ /^https:\/\/my-slides\.com\/slidev-workspace-starter\/slides-presentation-1\/og-image\.png\?v=\d+$/,
545
546
  );
546
547
  });
547
548
 
@@ -567,8 +568,8 @@ describe("useSlides (Production Mode)", () => {
567
568
 
568
569
  // First slide has hasOgImage: true, so should use og-image.png
569
570
  expect(firstSlide.image).toContain("og-image.png");
570
- expect(firstSlide.image).toBe(
571
- "https://my-slides.com/slidev-workspace-starter/og-image.png",
571
+ expect(firstSlide.image).toMatch(
572
+ /^https:\/\/my-slides\.com\/slidev-workspace-starter\/slides-presentation-1\/og-image\.png\?v=\d+$/,
572
573
  );
573
574
  });
574
575
 
@@ -40,7 +40,7 @@ export function resolveImageUrl(slide: SlideInfo, domain: string): string {
40
40
  const imagePath = `og-image.png?v=${Date.now()}`;
41
41
  try {
42
42
  const path = IS_DEVELOPMENT
43
- ? pathJoin(slidePath, imagePath)
43
+ ? imagePath
44
44
  : pathJoin(baseUrl, slidePath, imagePath);
45
45
 
46
46
  return new URL(path, domain).href;
@@ -74,7 +74,7 @@ export function resolveImageUrl(slide: SlideInfo, domain: string): string {
74
74
 
75
75
  try {
76
76
  return IS_DEVELOPMENT
77
- ? new URL(pathJoin(slidePath, background), domain).href
77
+ ? new URL(background, domain).href
78
78
  : new URL(pathJoin(baseUrl, slidePath, background), domain).href;
79
79
  } catch (error) {
80
80
  console.error("Failed to resolve background path:", error);