@aravindc26/velu 0.12.11 → 0.12.13

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aravindc26/velu",
3
- "version": "0.12.11",
3
+ "version": "0.12.13",
4
4
  "description": "A modern documentation site generator powered by Markdown and JSON configuration",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/cli.ts CHANGED
@@ -578,7 +578,7 @@ async function previewServer(port: number) {
578
578
  ...previewServerEnv(),
579
579
  // Align source.config.ts and content-generator on the same content dir
580
580
  PREVIEW_CONTENT_DIR: process.env.PREVIEW_CONTENT_DIR || "./content",
581
- WATCHPACK_POLLING: process.env.WATCHPACK_POLLING || "true",
581
+ WATCHPACK_POLLING: process.env.WATCHPACK_POLLING || "false",
582
582
  },
583
583
  });
584
584
 
@@ -1,7 +1,37 @@
1
1
  import { NextRequest } from 'next/server';
2
+ import { existsSync, utimesSync, statSync } from 'node:fs';
3
+ import { resolve } from 'node:path';
2
4
  import { generateSessionContent } from '@/lib/preview-content';
3
5
  import { verifyApiSecret, unauthorizedResponse } from '@/lib/preview-auth';
4
6
 
7
+ /**
8
+ * Touch source.config.ts to trigger fumadocs-mdx rescan,
9
+ * then wait for the .source output to regenerate.
10
+ */
11
+ async function triggerMdxRegeneration(): Promise<void> {
12
+ const configPath = resolve(process.cwd(), 'source.config.ts');
13
+ const sourceDir = resolve(process.cwd(), '.source');
14
+
15
+ // Record current .source mtime (if it exists)
16
+ const beforeMtime = existsSync(sourceDir)
17
+ ? statSync(sourceDir).mtimeMs
18
+ : 0;
19
+
20
+ // Touch source.config.ts to trigger chokidar → fumadocs-mdx full reload
21
+ const now = new Date();
22
+ utimesSync(configPath, now, now);
23
+
24
+ // Wait for .source directory to be updated (up to 30s)
25
+ for (let i = 0; i < 300; i++) {
26
+ await new Promise((r) => setTimeout(r, 100));
27
+ if (existsSync(sourceDir)) {
28
+ const currentMtime = statSync(sourceDir).mtimeMs;
29
+ if (currentMtime > beforeMtime) return;
30
+ }
31
+ }
32
+ console.warn('[PREVIEW] MDX regeneration timed out after 30s');
33
+ }
34
+
5
35
  export async function POST(
6
36
  request: NextRequest,
7
37
  { params }: { params: Promise<{ sessionId: string }> },
@@ -12,6 +42,10 @@ export async function POST(
12
42
 
13
43
  try {
14
44
  const result = generateSessionContent(sessionId);
45
+
46
+ // Trigger fumadocs-mdx to discover the new content files
47
+ await triggerMdxRegeneration();
48
+
15
49
  return Response.json({
16
50
  status: 'ready',
17
51
  url: `/${sessionId}/`,
@@ -2,7 +2,7 @@
2
2
  * Shared docs layout rendering logic.
3
3
  * Used by both (docs)/[...slug]/layout.tsx (production) and _preview/ routes.
4
4
  */
5
- import { isValidElement, type ReactNode } from 'react';
5
+ import React, { isValidElement, type ReactNode } from 'react';
6
6
  import { DocsLayout } from 'fumadocs-ui/layouts/notebook';
7
7
  import type { LinkItemType, BaseLayoutProps } from 'fumadocs-ui/layouts/shared';
8
8
  import { SidebarLinks } from '@/components/sidebar-links';
@@ -477,7 +477,7 @@ export interface DocsLayoutConfig {
477
477
  urlPrefix?: string;
478
478
  }
479
479
 
480
- export function renderDocsLayout(config: DocsLayoutConfig, children: ReactNode): JSX.Element {
480
+ export function renderDocsLayout(config: DocsLayoutConfig, children: ReactNode): React.JSX.Element {
481
481
  const {
482
482
  slug: slugInput,
483
483
  tree: localePageTree,
@@ -110,7 +110,7 @@ interface PageMapping {
110
110
 
111
111
  interface MetaFile {
112
112
  dir: string;
113
- data: { pages: string[]; title?: string; description?: string };
113
+ data: { pages: string[]; title?: string; description?: string; [key: string]: unknown };
114
114
  }
115
115
 
116
116
  interface BuildArtifacts {
@@ -415,7 +415,7 @@ function buildArtifacts(config: VeluConfig, docsDir?: string): BuildArtifacts {
415
415
  }
416
416
  }
417
417
 
418
- const groupMetaData: Record<string, unknown> = {
418
+ const groupMetaData: MetaFile['data'] = {
419
419
  title: group.group,
420
420
  pages: groupMetaPages,
421
421
  defaultOpen: group.expanded !== false,