File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff 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" ) {
You can’t perform that action at this time.
0 commit comments