-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split out preprocessSource into ./gatsby/`
- Loading branch information
1 parent
702cfb6
commit 38bf79b
Showing
2 changed files
with
18 additions
and
15 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
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,17 @@ | ||
const path = require("path"); | ||
const mdx = require("../utils/mdx"); | ||
const defaultOptions = require("../utils/default-options"); | ||
|
||
module.exports = async function preprocessSource( | ||
{ filename, contents }, | ||
pluginOptions | ||
) { | ||
const { extensions, ...options } = defaultOptions(pluginOptions); | ||
const ext = path.extname(filename); | ||
|
||
if (extensions.includes(ext)) { | ||
const code = await mdx(contents, options); | ||
return code; | ||
} | ||
return null; | ||
}; |