Skip to content

Commit

Permalink
fix(v2): fix multi-instance mdx loaders not sandboxed correctly (#3970)
Browse files Browse the repository at this point in the history
* another attempt to fix the multi-instance conflicts

* try to fix windows build

* cleanup + improve comment
  • Loading branch information
slorber committed Dec 30, 2020
1 parent 9fdac1a commit 1e18606
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 3 deletions.
5 changes: 4 additions & 1 deletion packages/docusaurus-plugin-content-blog/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getPluginI18nPath,
reportMessage,
posixPath,
addTrailingPathSeparator,
} from '@docusaurus/utils';
import {
STATIC_DIR_NAME,
Expand Down Expand Up @@ -436,7 +437,9 @@ export default function pluginContentBlog(
rules: [
{
test: /(\.mdx?)$/,
include: getContentPathList(contentPaths),
include: getContentPathList(contentPaths)
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
.map(addTrailingPathSeparator),
use: [
getCacheLoader(isServer),
getBabelLoader(isServer),
Expand Down
5 changes: 4 additions & 1 deletion packages/docusaurus-plugin-content-docs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
aliasedSitePath,
reportMessage,
posixPath,
addTrailingPathSeparator,
} from '@docusaurus/utils';
import {LoadContext, Plugin, RouteConfig} from '@docusaurus/types';

Expand Down Expand Up @@ -345,7 +346,9 @@ export default function pluginContentDocs(
function createMDXLoaderRule(): RuleSetRule {
return {
test: /(\.mdx?)$/,
include: flatten(versionsMetadata.map(getDocsDirPaths)),
include: flatten(versionsMetadata.map(getDocsDirPaths))
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
.map(addTrailingPathSeparator),
use: compact([
getCacheLoader(isServer),
getBabelLoader(isServer),
Expand Down
5 changes: 4 additions & 1 deletion packages/docusaurus-plugin-content-pages/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
docuHash,
getPluginI18nPath,
getFolderContainingFile,
addTrailingPathSeparator,
} from '@docusaurus/utils';
import {
LoadContext,
Expand Down Expand Up @@ -210,7 +211,9 @@ export default function pluginContentPages(
rules: [
{
test: /(\.mdx?)$/,
include: getContentPathList(contentPaths),
include: getContentPathList(contentPaths)
// Trailing slash is important, see https://github.com/facebook/docusaurus/pull/3970
.map(addTrailingPathSeparator),
use: [
getCacheLoader(isServer),
getBabelLoader(isServer),
Expand Down
3 changes: 3 additions & 0 deletions packages/docusaurus-utils/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,9 @@ export function addLeadingSlash(str: string): string {
export function addTrailingSlash(str: string): string {
return str.endsWith('/') ? str : `${str}/`;
}
export function addTrailingPathSeparator(str: string): string {
return str.endsWith(path.sep) ? str : `${str}${path.sep}`;
}

export function removeTrailingSlash(str: string): string {
return removeSuffix(str, '/');
Expand Down

0 comments on commit 1e18606

Please sign in to comment.