Skip to content

Commit

Permalink
fix: use platform agnostic paths
Browse files Browse the repository at this point in the history
  • Loading branch information
devdigital authored and ChristopherBiscardi committed Jun 27, 2019
1 parent 38bf79b commit 75adee3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
12 changes: 5 additions & 7 deletions packages/gatsby-plugin-mdx/component-with-mdx-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const path = require("path");
const babel = require("@babel/core");
const syntaxObjRestSpread = require("@babel/plugin-syntax-object-rest-spread");
const debug = require("debug")("gatsby-mdx:component-with-mdx-scope");
const slash = require("slash");

const BabelPluginPluckExports = require("babel-plugin-pluck-exports");

Expand All @@ -28,11 +29,8 @@ module.exports = function componentWithMDXScope(

const scopeHashes = codeScopeAbsPaths.map(codeScopeAbsPath => {
// get the preexisting hash for the scope file to use in the new wrapper filename
const scopePathSegments = codeScopeAbsPath.split("/");
const scopeHash = scopePathSegments[scopePathSegments.length - 1].slice(
0,
-3
);
const base = path.parse(codeScopeAbsPath).base;
const scopeHash = base.slice(0, -3);
return scopeHash;
});

Expand All @@ -44,10 +42,10 @@ import React from 'react';
import { MDXScopeProvider } from 'gatsby-mdx/context';
${codeScopeAbsPaths
.map((scopePath, i) => `import __mdxScope_${i} from '${scopePath}';`)
.map((scopePath, i) => `import __mdxScope_${i} from '${slash(scopePath)}';`)
.join("\n")}
import OriginalWrapper from '${absWrapperPath}';
import OriginalWrapper from '${slash(absWrapperPath)}';
import { graphql } from 'gatsby';
Expand Down
3 changes: 2 additions & 1 deletion packages/gatsby-plugin-mdx/loaders/mdx-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const getSourcePluginsAsRemarkPlugins = require("../utils/get-source-plugins-as-
const withDefaultOptions = require("../utils/default-options");
const createMDXNode = require("../utils/create-mdx-node");
const { createFileNode } = require("../utils/create-fake-file-node");
const slash = require("slash");

const DEFAULT_OPTIONS = {
footnotes: true,
Expand Down Expand Up @@ -129,7 +130,7 @@ module.exports = async function(content) {
debug("inserting default layout", defaultLayout);
const { content: contentWithoutFrontmatter } = grayMatter(content);

code = `import DefaultLayout from "${defaultLayout}"
code = `import DefaultLayout from "${slash(defaultLayout)}"
export default DefaultLayout
Expand Down
1 change: 1 addition & 0 deletions packages/gatsby-plugin-mdx/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"mdast-util-toc": "^2.0.1",
"remark": "^9.0.0",
"retext": "^5.0.0",
"slash": "^2.0.0",
"strip-markdown": "^3.0.1",
"underscore.string": "^3.3.4",
"unist-util-map": "^1.0.4",
Expand Down

0 comments on commit 75adee3

Please sign in to comment.