An open API service indexing awesome lists of open source software.

https://github.com/nesterow/watch_mdx

Compile mdx files to jsx on fly.
https://github.com/nesterow/watch_mdx

deno mdx mdx-js

Last synced: 3 months ago
JSON representation

Compile mdx files to jsx on fly.

Awesome Lists containing this project

README

          

# Watch MDX

Compile MDX to JSX on fly..

## Usage

```typescript
import { watchMdx } from "https://deno.land/x/watch_mdx/mod.ts";

watchMdx({
compile: async ({ compile, source, output }) => {
const result = await compile(source.value, {
jsxImportSource: "preact",
jsx: true,
});
return {
value: result.value,
output: output,
};
},
});
```

## API

Everything can be modified through options.

### watchMdx(options: WatcherOptions) - Watcher

Watch directory for changes and compile mdx files.

### copileMdx(options: WatcherOptions) - Compiler

Collect all mdx files and compile them.

### WatcherOptions

```typescript
interface WatcherOptions {
dir: string; // default: cwd
pattern: RegExp; // default: /\.mdx$/
compile: CompilerCallback;
onCompile: Callback;
precompile: boolean; // compile all before init?
denoFormat: boolean; // format output with deno fmt?
formatOutput: (input: string) => string; // custom path/ext
}
```

## Example

[dev.ts](https://github.com/nesterow/tailored/blob/main/dev.ts)

## License

MIT