Skip to content

Commit aa18733

Browse files
authored
Update posixPath to wrap path.join to fix backslash issue when buildi… (#332)
* Update posixPath to wrap path.join to fix backslash issue when building on Windows * fix lint errors
1 parent 13dfde0 commit aa18733

File tree

4 files changed

+17
-7
lines changed

4 files changed

+17
-7
lines changed

packages/docusaurus-plugin-openapi-docs/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import fs from "fs";
99
import path from "path";
1010

1111
import type { LoadContext, Plugin } from "@docusaurus/types";
12-
import { Globby } from "@docusaurus/utils";
12+
import { Globby, posixPath } from "@docusaurus/utils";
1313
import chalk from "chalk";
1414
import { render } from "mustache";
1515

@@ -338,7 +338,7 @@ import {useCurrentSidebarCategory} from '@docusaurus/theme-common';
338338

339339
async function cleanApiDocs(options: APIOptions) {
340340
const { outputDir } = options;
341-
const apiDir = path.join(siteDir, outputDir);
341+
const apiDir = posixPath(path.join(siteDir, outputDir));
342342
const apiMdxFiles = await Globby(["*.api.mdx", "*.info.mdx", "*.tag.mdx"], {
343343
cwd: path.resolve(apiDir),
344344
deep: 1,

packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77

88
import path from "path";
99

10+
import { posixPath } from "@docusaurus/utils";
11+
1012
import { readOpenapiFiles } from ".";
1113

1214
// npx jest packages/docusaurus-plugin-openapi/src/openapi/openapi.test.ts --watch
@@ -15,7 +17,7 @@ describe("openapi", () => {
1517
describe("readOpenapiFiles", () => {
1618
it("readOpenapiFiles", async () => {
1719
const results = await readOpenapiFiles(
18-
path.join(__dirname, "__fixtures__/examples"),
20+
posixPath(path.join(__dirname, "__fixtures__/examples")),
1921
{ specPath: "./", outputDir: "./" }
2022
);
2123
const categoryMeta = results.find((x) =>

packages/docusaurus-plugin-openapi-docs/src/openapi/openapi.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
import path from "path";
99

10-
import { Globby, GlobExcludeDefault } from "@docusaurus/utils";
10+
import { Globby, GlobExcludeDefault, posixPath } from "@docusaurus/utils";
1111
import Converter from "@paloaltonetworks/openapi-to-postmanv2";
1212
import sdk from "@paloaltonetworks/postman-collection";
1313
import Collection from "@paloaltonetworks/postman-collection";
@@ -320,7 +320,7 @@ export async function readOpenapiFiles(
320320
return Promise.all(
321321
sources.map(async (source) => {
322322
// TODO: make a function for this
323-
const fullPath = path.join(openapiPath, source);
323+
const fullPath = posixPath(path.join(openapiPath, source));
324324
const data = (await loadAndResolveSpec(
325325
fullPath
326326
)) as unknown as OpenApiObject;

packages/docusaurus-plugin-openapi-docs/src/sidebars/index.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
SidebarItemCategoryLinkConfig,
1414
SidebarItemDoc,
1515
} from "@docusaurus/plugin-content-docs/src/sidebars/types";
16+
import { posixPath } from "@docusaurus/utils";
1617
import clsx from "clsx";
1718
import { kebabCase } from "lodash";
1819
import uniq from "lodash/uniq";
@@ -148,8 +149,15 @@ function groupByTags(
148149
type: "generated-index" as "generated-index",
149150
title: tag,
150151
slug: label
151-
? path.join("/category", basePath, kebabCase(label), kebabCase(tag))
152-
: path.join("/category", basePath, kebabCase(tag)),
152+
? posixPath(
153+
path.join(
154+
"/category",
155+
basePath,
156+
kebabCase(label),
157+
kebabCase(tag)
158+
)
159+
)
160+
: posixPath(path.join("/category", basePath, kebabCase(tag))),
153161
} as SidebarItemCategoryLinkConfig;
154162
}
155163

0 commit comments

Comments
 (0)