forked from hashicorp/next-mdx-remote
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Typescript Type Definitions (hashicorp#70)
* add typing for hydrate * refine types * further refinement, break into separate files, update test to use ts * 1.0.1-canary.0 * add type docs to readme
- Loading branch information
Showing
12 changed files
with
3,200 additions
and
1,042 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,5 @@ | ||
__tests__ | ||
examples | ||
.prettierrc | ||
.prettierrc | ||
tsconfig.json | ||
babel.config.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
module.exports = { | ||
presets: [ | ||
['@babel/preset-env', { targets: { node: 'current' } }], | ||
'@babel/preset-typescript', | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { ReactNode } from 'react' | ||
import { MdxRemote } from 'types' | ||
|
||
export default function hydrate( | ||
/** Rendered MDX output. The direct output of `renderToString`. */ | ||
source: MdxRemote.Source, | ||
/** | ||
* A map of names to React components. | ||
* The key used will be the name accessible to MDX. | ||
* | ||
* For example: `{ ComponentName: Component }` will be accessible in the MDX as `<ComponentName/>`. | ||
*/ | ||
options: { components: MdxRemote.Components } | ||
): ReactNode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import hydrate from 'hydrate' | ||
import renderToString from 'render-to-string' | ||
|
||
declare module 'next-mdx-remote/render-to-string' { | ||
export default renderToString | ||
} | ||
|
||
declare module 'next-mdx-remote/hydrate' { | ||
export default hydrate | ||
} |
Oops, something went wrong.