Skip to content

Commit 58ba7d6

Browse files
committed
fix: use process.cwd() instead of vfile.cwd for docs path resolution
1 parent 9e98334 commit 58ba7d6

1 file changed

Lines changed: 10 additions & 6 deletions

File tree

website/src/remark/time.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,19 @@ const plugin = (options) => {
3434
const attributes = { ...defaultAttributes, ...node.attributes };
3535

3636
const filePath = vfile.history[0];
37+
const projectDir = process.cwd();
38+
const docsDir = `${projectDir}/docs`;
3739
let relativePath;
3840

39-
if (locale === "en") {
40-
relativePath = path.relative(`${vfile.cwd}/docs`, filePath);
41+
if (locale !== "en") {
42+
const i18nDocsDir = `${projectDir}/i18n/${locale}/docusaurus-plugin-content-docs/current`;
43+
if (filePath.startsWith(i18nDocsDir)) {
44+
relativePath = path.relative(i18nDocsDir, filePath);
45+
} else {
46+
relativePath = path.relative(docsDir, filePath);
47+
}
4148
} else {
42-
relativePath = path.relative(
43-
`${vfile.cwd}/i18n/${locale}/docusaurus-plugin-content-docs/current`,
44-
filePath,
45-
);
49+
relativePath = path.relative(docsDir, filePath);
4650
}
4751

4852
if (attributes.estimatedLabExecutionTimeMinutes === "0") {

0 commit comments

Comments
 (0)