Skip to content

Commit

Permalink
fix: Fix images path resolution one more time
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 6, 2024
1 parent 15e6d75 commit 37a4c8e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/resolvers/md2html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {ArgvService, PluginService, SearchService, TocService} from '../services
import {getVCSMetadata} from '../services/metadata';
import {
getDepth,
getDepthPath,
getLinksWithContentExtersion,
getVarsPerFile,
getVarsPerRelativeFile,
Expand Down Expand Up @@ -229,7 +228,7 @@ function MdFileTransformer(content: string, transformOptions: FileTransformOptio
vars,
root,
path,
assetsPublicPath: getDepthPath(dirname(filePath)),
assetsPublicPath: './',
getVarsPerFile: getVarsPerRelativeFile,
getPublicPath,
extractTitle: true,
Expand Down
9 changes: 5 additions & 4 deletions src/utils/path.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ export function convertBackSlashToSlash(path: string): string {
}

export function getDepth(path: string) {
return path.replace(/\\/g, '/').split('/').length;
return path
.replace(/\\/g, '/')
.replace(/^\.\/|\/$/g, '')
.split('/').length;
}

export function getDepthPath(path: string | number) {
const depth = typeof path === 'number' ? path : getDepth(path) - 1;

export function getDepthPath(depth: number) {
return Array(depth).fill('../').join('') || './';
}

0 comments on commit 37a4c8e

Please sign in to comment.