diff --git a/packages/docusaurus-plugin-content-blog/src/feed.ts b/packages/docusaurus-plugin-content-blog/src/feed.ts index f9053bec3417..fa546fbf0f18 100644 --- a/packages/docusaurus-plugin-content-blog/src/feed.ts +++ b/packages/docusaurus-plugin-content-blog/src/feed.ts @@ -9,7 +9,6 @@ import {Feed, type Author as FeedAuthor, type Item as FeedItem} from 'feed'; import type {BlogPost} from './types'; import { normalizeUrl, - posixPath, mapAsyncSequential, readOutputHTMLFile, } from '@docusaurus/utils'; @@ -128,10 +127,7 @@ async function createBlogFeedFile({ } })(); try { - await fs.outputFile( - posixPath(path.join(generatePath, feedPath)), - feedContent, - ); + await fs.outputFile(path.join(generatePath, feedPath), feedContent); } catch (err) { throw new Error(`Generating ${feedType} feed failed: ${err}.`); } diff --git a/packages/docusaurus-plugin-content-docs/src/__tests__/cli.test.ts b/packages/docusaurus-plugin-content-docs/src/__tests__/cli.test.ts index 8ca46aeb8195..22aeed790cb9 100644 --- a/packages/docusaurus-plugin-content-docs/src/__tests__/cli.test.ts +++ b/packages/docusaurus-plugin-content-docs/src/__tests__/cli.test.ts @@ -181,7 +181,7 @@ describe('docsVersion', () => { DEFAULT_OPTIONS, ), ).rejects.toThrowErrorMatchingInlineSnapshot( - `"[docs]: there is no docs to version!"`, + `"[docs]: no docs found in /packages/docusaurus-plugin-content-docs/src/__tests__/__fixtures__/empty-site/docs."`, ); }); diff --git a/packages/docusaurus-plugin-content-docs/src/cli.ts b/packages/docusaurus-plugin-content-docs/src/cli.ts index 2aaceff79b2d..710a5c3d7c67 100644 --- a/packages/docusaurus-plugin-content-docs/src/cli.ts +++ b/packages/docusaurus-plugin-content-docs/src/cli.ts @@ -117,7 +117,7 @@ export async function cliDocsVersionCommand( const {path: docsPath, sidebarPath} = options; // Copy docs files. - const docsDir = path.join(siteDir, docsPath); + const docsDir = path.resolve(siteDir, docsPath); if ( (await fs.pathExists(docsDir)) && @@ -127,7 +127,7 @@ export async function cliDocsVersionCommand( const newVersionDir = path.join(versionedDir, `version-${version}`); await fs.copy(docsDir, newVersionDir); } else { - throw new Error(`${pluginIdLogPrefix}: there is no docs to version!`); + throw new Error(`${pluginIdLogPrefix}: no docs found in ${docsDir}.`); } await createVersionedSidebarFile({ diff --git a/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts b/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts index 928731fc4fc5..4642897f3df4 100644 --- a/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts +++ b/packages/docusaurus-plugin-content-docs/src/sidebars/generator.ts @@ -14,7 +14,7 @@ import type { SidebarItemCategoryLinkConfig, } from './types'; import _ from 'lodash'; -import {addTrailingSlash, posixPath} from '@docusaurus/utils'; +import {addTrailingSlash} from '@docusaurus/utils'; import logger from '@docusaurus/logger'; import path from 'path'; import {createDocsByIdIndex, toCategoryIndexMatcherParam} from '../docs'; @@ -157,7 +157,7 @@ Available doc IDs: folderName: string, ): WithPosition { const categoryMetadata = - categoriesMetadata[posixPath(path.join(autogenDir, fullPath))]; + categoriesMetadata[path.posix.join(autogenDir, fullPath)]; const allItems = Object.entries(dir).map(([key, content]) => dirToItem(content, key, `${fullPath}/${key}`), ); diff --git a/packages/docusaurus-utils/src/dataFileUtils.ts b/packages/docusaurus-utils/src/dataFileUtils.ts index 58fc8151165e..34ed9befeb83 100644 --- a/packages/docusaurus-utils/src/dataFileUtils.ts +++ b/packages/docusaurus-utils/src/dataFileUtils.ts @@ -37,7 +37,7 @@ export async function getDataFilePath({ filePath, ); if (contentPath) { - return path.join(contentPath, filePath); + return path.resolve(contentPath, filePath); } return undefined; } diff --git a/packages/docusaurus/src/commands/serve.ts b/packages/docusaurus/src/commands/serve.ts index 72f79bc06fbe..eed951fda525 100644 --- a/packages/docusaurus/src/commands/serve.ts +++ b/packages/docusaurus/src/commands/serve.ts @@ -18,9 +18,7 @@ export default async function serve( siteDir: string, cliOptions: ServeCLIOptions, ): Promise { - let dir = path.isAbsolute(cliOptions.dir) - ? cliOptions.dir - : path.join(siteDir, cliOptions.dir); + let dir = path.resolve(siteDir, cliOptions.dir); if (cliOptions.build) { dir = await build( diff --git a/packages/docusaurus/src/server/translations/translations.ts b/packages/docusaurus/src/server/translations/translations.ts index 0cd6b0b37313..ba749f0aeff5 100644 --- a/packages/docusaurus/src/server/translations/translations.ts +++ b/packages/docusaurus/src/server/translations/translations.ts @@ -145,7 +145,7 @@ Maybe you should remove them? ${unknownKeys}`; // should we make this configurable? function getTranslationsDirPath(context: TranslationContext): string { - return path.resolve(path.join(context.siteDir, I18N_DIR_NAME)); + return path.join(context.siteDir, I18N_DIR_NAME); } export function getTranslationsLocaleDirPath( context: TranslationContext,