MDX: expose start function from loader

This commit is contained in:
fuma-nama
2024-10-04 17:25:49 +08:00
parent 8a32f79076
commit 9a964ca379
3 changed files with 13 additions and 1 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'fumadocs-mdx': patch
---
expose `start` function from loader
+6 -1
View File
@@ -1,11 +1,15 @@
import path from 'node:path';
import fs from 'node:fs';
import { type EventName } from 'chokidar/handler.js';
import { watcher } from '@/map/watcher';
import { getConfigHash, loadConfigCached } from '@/config/cached';
import { generateJS, generateTypes } from '@/map/generate';
import { writeManifest } from '@/map/manifest';
/**
* Start a MDX server that builds index and manifest files.
*
* In development mode, it starts a file watcher to auto-update output as your input changes.
*/
export async function start(
dev: boolean,
configPath: string,
@@ -18,6 +22,7 @@ export async function start(
const typeOut = path.resolve(outDir, `index.d.ts`);
if (dev) {
const { watcher } = await import('@/map/watcher');
const instance = watcher(configPath, config);
instance.on('ready', () => {
+2
View File
@@ -15,6 +15,8 @@ export interface CreateMDXOptions {
const outDir = path.resolve('.source');
const defaultPageExtensions = ['mdx', 'md', 'jsx', 'js', 'tsx', 'ts'];
export { start };
export function createMDX({
configPath = findConfigFile(),
}: CreateMDXOptions = {}) {