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.
- Host: GitHub
- URL: https://github.com/nesterow/watch_mdx
- Owner: nesterow
- License: mit
- Created: 2023-02-15T10:15:38.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2023-02-16T19:04:23.000Z (over 3 years ago)
- Last Synced: 2025-12-26T11:45:21.950Z (6 months ago)
- Topics: deno, mdx, mdx-js
- Language: TypeScript
- Homepage: https://deno.land/x/watch_mdx
- Size: 23.4 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
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