Commit 75adee3 1 parent 38bf79b commit 75adee3 Copy full SHA for 75adee3
File tree 3 files changed +8
-8
lines changed
packages/gatsby-plugin-mdx
3 files changed +8
-8
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ const path = require("path");
4
4
const babel = require ( "@babel/core" ) ;
5
5
const syntaxObjRestSpread = require ( "@babel/plugin-syntax-object-rest-spread" ) ;
6
6
const debug = require ( "debug" ) ( "gatsby-mdx:component-with-mdx-scope" ) ;
7
+ const slash = require ( "slash" ) ;
7
8
8
9
const BabelPluginPluckExports = require ( "babel-plugin-pluck-exports" ) ;
9
10
@@ -28,11 +29,8 @@ module.exports = function componentWithMDXScope(
28
29
29
30
const scopeHashes = codeScopeAbsPaths . map ( codeScopeAbsPath => {
30
31
// get the preexisting hash for the scope file to use in the new wrapper filename
31
- const scopePathSegments = codeScopeAbsPath . split ( "/" ) ;
32
- const scopeHash = scopePathSegments [ scopePathSegments . length - 1 ] . slice (
33
- 0 ,
34
- - 3
35
- ) ;
32
+ const base = path . parse ( codeScopeAbsPath ) . base ;
33
+ const scopeHash = base . slice ( 0 , - 3 ) ;
36
34
return scopeHash ;
37
35
} ) ;
38
36
@@ -44,10 +42,10 @@ import React from 'react';
44
42
import { MDXScopeProvider } from 'gatsby-mdx/context';
45
43
46
44
${ codeScopeAbsPaths
47
- . map ( ( scopePath , i ) => `import __mdxScope_${ i } from '${ scopePath } ';` )
45
+ . map ( ( scopePath , i ) => `import __mdxScope_${ i } from '${ slash ( scopePath ) } ';` )
48
46
. join ( "\n" ) }
49
47
50
- import OriginalWrapper from '${ absWrapperPath } ';
48
+ import OriginalWrapper from '${ slash ( absWrapperPath ) } ';
51
49
52
50
import { graphql } from 'gatsby';
53
51
Original file line number Diff line number Diff line change @@ -19,6 +19,7 @@ const getSourcePluginsAsRemarkPlugins = require("../utils/get-source-plugins-as-
19
19
const withDefaultOptions = require ( "../utils/default-options" ) ;
20
20
const createMDXNode = require ( "../utils/create-mdx-node" ) ;
21
21
const { createFileNode } = require ( "../utils/create-fake-file-node" ) ;
22
+ const slash = require ( "slash" ) ;
22
23
23
24
const DEFAULT_OPTIONS = {
24
25
footnotes : true ,
@@ -129,7 +130,7 @@ module.exports = async function(content) {
129
130
debug ( "inserting default layout" , defaultLayout ) ;
130
131
const { content : contentWithoutFrontmatter } = grayMatter ( content ) ;
131
132
132
- code = `import DefaultLayout from "${ defaultLayout } "
133
+ code = `import DefaultLayout from "${ slash ( defaultLayout ) } "
133
134
134
135
135
136
export default DefaultLayout
Original file line number Diff line number Diff line change 26
26
"mdast-util-toc" : " ^2.0.1" ,
27
27
"remark" : " ^9.0.0" ,
28
28
"retext" : " ^5.0.0" ,
29
+ "slash" : " ^2.0.0" ,
29
30
"strip-markdown" : " ^3.0.1" ,
30
31
"underscore.string" : " ^3.3.4" ,
31
32
"unist-util-map" : " ^1.0.4" ,
You can’t perform that action at this time.
0 commit comments