0.1.44 • Published 8 months ago
@moneko/mdx v0.1.44
@moneko/mdx
Install
# npm
npm install @moneko/mdx
# yarn
yarn add @moneko/mdx
# pnpm
pnpm install @moneko/mdxUsage
mdx
异步转换mdx
import { mdx } from "@moneko/mdx";
async function main() {
  const value = `
  # Hello World
  This is a demo of @moneko/mdx
  `;
  const result = await mdx({
    value,
    filepath: "xxx.mdx",
    jsx: false,
    development: true,
  });
  console.log(result);
}mdxSync
同步转换mdx
import { mdxSync } from "@moneko/mdx";
function main() {
  const value = `
  # Hello World
  This is a demo of @moneko/mdx
  `;
  const result = mdxSync({
    value,
    filepath: "xxx.mdx",
    jsx: false,
    development: true,
  });
  console.log(result);
}frontmatter
异步提取md中的frontmatter
import { frontmatter } from "@moneko/mdx";
async function main() {
  const value = `---
title: "Sample Title"
author: "Author Name"
---
## header
> This is some content.
`;
  const result = await frontmatter({
    value,
    filepath: "xxx.mdx",
    jsx: false,
    development: true,
  });
  console.log(result.frontmatter);
}frontmatterSync
同步提取md中的frontmatter
import { frontmatterSync } from "@moneko/mdx";
function main() {
  const value = `---
title: "Sample Title"
author: "Author Name"
---
## header
> This is some content.
`;
  const result = frontmatterSync({
    value,
    filepath: "xxx.mdx",
    jsx: false,
    development: true,
  });
  console.log(result.frontmatter);
}jsxImportSource
import { mdx } from "@moneko/mdx";
async function main() {
  const value = `
  # Hello World
  This is a demo of @moneko/mdx
  `;
  const result = await mdx({
    value,
    filepath: "xxx.mdx",
    jsx: false,
    development: true,
    jsxImportSource: 'preact',
    providerImportSource: '@mdx/preact'
  });
  console.log(result);
}MdxOptions
interface MdxOptions {
  value: string
  filepath?: string
  development: boolean
  providerImportSource?: string
  jsx?: boolean
  jsxRuntime?: string
  jsxImportSource?: string
  pragma?: string
  pragmaFrag?: string
  pragmaImportSource?: string
}Credits
Thanks to mdxjs-rs, the awesome Rust library authored by wooorm.
Also, thanks to napi-rs, authored by Brooooooklyn, which is a great solution to help us build Node.js binding for Rust.
0.1.41
12 months ago
0.1.42
11 months ago
0.1.43
10 months ago
0.1.44
8 months ago
0.1.40
12 months ago
0.1.30
1 year ago
0.1.31
1 year ago
0.1.32
1 year ago
0.1.33
1 year ago
0.1.35
1 year ago
0.1.27
1 year ago
0.1.28
1 year ago
0.1.29
1 year ago
0.1.39
1 year ago
0.1.25
2 years ago
0.1.26
2 years ago
0.1.22
2 years ago
0.1.23
2 years ago
0.1.21
2 years ago
0.1.20
2 years ago
0.1.19
2 years ago
0.1.16
2 years ago
0.1.17
2 years ago
0.1.18
2 years ago
0.1.14
2 years ago
0.1.13
2 years ago
0.1.12
2 years ago
0.1.10
2 years ago
0.1.9
2 years ago
0.1.7
2 years ago
0.1.6
2 years ago
0.0.6
2 years ago
0.0.4
2 years ago