Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add type definitions for next/mdx #36815

Merged
merged 10 commits into from
May 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"@babel/preset-flow": "7.14.5",
"@babel/preset-react": "7.14.5",
"@fullhuman/postcss-purgecss": "1.3.0",
"@mdx-js/loader": "0.18.0",
"@mdx-js/loader": "2.1.1",
"@svgr/webpack": "5.5.0",
"@swc/cli": "0.1.55",
"@swc/core": "1.2.148",
Expand Down
31 changes: 31 additions & 0 deletions packages/next-mdx/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { NextConfig } from 'next'
import { CompileOptions } from '@mdx-js/mdx'
import { RuleSetConditionAbsolute } from 'webpack'

type WithMDX = (config: NextConfig) => NextConfig

interface NextMDXOptions {
/**
* A webpack rule test to match files to treat as MDX.
*
* @default /\.mdx$/
* @example
* // Support both .md and .mdx files.
* /\.mdx?$/
*/
extension?: RuleSetConditionAbsolute

/**
* The options to pass to MDX.
*
* @see https://mdxjs.com/packages/mdx/#api
*/
options?: CompileOptions
}

/**
* Use [MDX](https://github.com/mdx-js/mdx) with [Next.js](https://github.com/vercel/next.js)
*/
declare function nextMDX(options?: NextMDXOptions): WithMDX

export = nextMDX
ijjk marked this conversation as resolved.
Show resolved Hide resolved
5 changes: 5 additions & 0 deletions packages/next-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
"url": "vercel/next.js",
"directory": "packages/next-mdx"
},
"dependencies": {
"@mdx-js/mdx": "^2.0.0",
"next": "12.1.7-canary.3",
"webpack": "^5.0.0"
},
"peerDependencies": {
"@mdx-js/loader": ">=0.15.0",
"@mdx-js/react": "*"
ijjk marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
9 changes: 9 additions & 0 deletions packages/next-mdx/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "../../tsconfig-tsec.json",
"compilerOptions": {
"strict": true,
"module": "commonjs",
"target": "es2017",
"moduleResolution": "node"
}
}
Loading