mirror of
https://github.com/hanzo-docs/docs.git
synced 2026-10-25 04:20:02 +00:00
CLI: fix Windows path problems
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@fumadocs/cli': patch
|
||||
---
|
||||
|
||||
Fix Windows path problems
|
||||
@@ -67,21 +67,32 @@ export async function transformReferences(
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the import modifier for `sourceFile` to import `referenceFile`
|
||||
*
|
||||
* @example
|
||||
* ```ts
|
||||
* toReferencePath('index.ts', 'dir/hello.ts')
|
||||
* // should output './dir/hello'
|
||||
* ```
|
||||
*/
|
||||
export function toReferencePath(
|
||||
sourceFile: string,
|
||||
referenceFile: string,
|
||||
): string {
|
||||
const extname = path.extname(referenceFile);
|
||||
const importPath = path.relative(
|
||||
path.dirname(sourceFile),
|
||||
path.join(
|
||||
path.dirname(referenceFile),
|
||||
path.basename(
|
||||
referenceFile,
|
||||
typescriptExtensions.includes(extname) ? extname : undefined,
|
||||
const importPath = path
|
||||
.relative(
|
||||
path.dirname(sourceFile),
|
||||
path.join(
|
||||
path.dirname(referenceFile),
|
||||
path.basename(
|
||||
referenceFile,
|
||||
typescriptExtensions.includes(extname) ? extname : undefined,
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
)
|
||||
.replaceAll(path.sep, '/');
|
||||
|
||||
return importPath.startsWith('../') ? importPath : `./${importPath}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user