Skip to content

Commit

Permalink
editUrl fn => always inject posix style relative paths, make tests mo…
Browse files Browse the repository at this point in the history
…re reliable

(see also #4124)
  • Loading branch information
slorber committed Jan 29, 2021
1 parent 8344061 commit 26be22c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 3 additions & 2 deletions packages/docusaurus-plugin-content-blog/src/blogUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import {
aliasedSitePath,
getEditUrl,
getFolderContainingFile,
posixPath,
} from '@docusaurus/utils';
import {LoadContext} from '@docusaurus/types';
import {keyBy} from 'lodash';
Expand Down Expand Up @@ -143,8 +144,8 @@ export async function generateBlogPosts(

if (typeof siteEditUrl === 'function') {
return siteEditUrl({
blogDirPath: path.relative(siteDir, blogDirPath),
blogPath: blogPathRelative, // good enough doc info for now?
blogDirPath: posixPath(path.relative(siteDir, blogDirPath)),
blogPath: posixPath(blogPathRelative),
locale: i18n.currentLocale,
});
} else if (typeof siteEditUrl === 'string') {
Expand Down
7 changes: 5 additions & 2 deletions packages/docusaurus-plugin-content-docs/src/docs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
getFolderContainingFile,
normalizeUrl,
parseMarkdownString,
posixPath,
} from '@docusaurus/utils';
import {LoadContext} from '@docusaurus/types';

Expand Down Expand Up @@ -124,8 +125,10 @@ export function processDocMetadata({
if (typeof options.editUrl === 'function') {
return options.editUrl({
version: versionMetadata.versionName,
versionDocsDirPath: path.relative(siteDir, versionMetadata.docsDirPath),
docPath: relativeFilePath, // good enough doc info for now?
versionDocsDirPath: posixPath(
path.relative(siteDir, versionMetadata.docsDirPath),
),
docPath: posixPath(relativeFilePath),
locale: context.i18n.currentLocale,
});
} else if (typeof options.editUrl === 'string') {
Expand Down

0 comments on commit 26be22c

Please sign in to comment.