UNPKG

1.55 kBTypeScriptView Raw
1import type {Root} from 'hast'
2import type {Plugin} from 'unified'
3import type {Options} from './lib/index.js'
4
5export type {Components, Options} from 'hast-util-to-jsx-runtime'
6
7/**
8 * Turn HTML into preact, react, solid, svelte, vue, etc.
9 *
10 * ###### Result
11 *
12 * This plugin registers a compiler that returns a `JSX.Element` where
13 * compilers typically return `string`.
14 * When using `.stringify` on `unified`, the result is such a `JSX.Element`.
15 * When using `.process` (or `.processSync`), the result is available at
16 * `file.result`.
17 *
18 * ###### Frameworks
19 *
20 * There are differences between what JSX frameworks accept, such as whether
21 * they accept `class` or `className`, or `background-color` or
22 * `backgroundColor`.
23 *
24 * For hast elements transformed by this project, this is be handled through
25 * options:
26 *
27 * | Framework | `elementAttributeNameCase` | `stylePropertyNameCase` |
28 * | --------- | -------------------------- | ----------------------- |
29 * | Preact | `'html'` | `'dom'` |
30 * | React | `'react'` | `'dom'` |
31 * | Solid | `'html'` | `'css'` |
32 * | Vue | `'html'` | `'dom'` |
33 *
34 * @param options
35 * Configuration (required).
36 * @returns
37 * Nothing.
38 */
39declare const rehypeReact: Plugin<[Options], Root, JSX.Element>
40export default rehypeReact
41
42// Register the result type.
43declare module 'unified' {
44 interface CompileResultMap {
45 JsxElement: JSX.Element
46 }
47}