Skip to content

Commit

Permalink
Merge pull request #752 from diplodoc-platform/add-relative-path-reso…
Browse files Browse the repository at this point in the history
…lution

feat: add relative path resolution for links
  • Loading branch information
makamekm authored Apr 26, 2024
2 parents a7fe67a + 9939666 commit 8057b0f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/resolvers/md2html.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import yaml from 'js-yaml';
import {Lang, PROCESSING_FINISHED} from '../constants';
import {LeadingPage, ResolverOptions, YfmToc} from '../models';
import {ArgvService, PluginService, TocService} from '../services';
import {getAssetsPublicPath, getVCSMetadata} from '../services/metadata';
import {getAssetsPublicPath, getAssetsRootPath, getVCSMetadata} from '../services/metadata';
import {
generateStaticMarkup,
getLinksWithContentExtersion,
Expand Down Expand Up @@ -187,6 +187,7 @@ function MdFileTransformer(content: string, transformOptions: FileTransformOptio
root,
path,
assetsPublicPath: getAssetsPublicPath(filePath),
rootPublicPath: getAssetsRootPath(filePath),
getVarsPerFile: getVarsPerRelativeFile,
extractTitle: true,
});
Expand Down
7 changes: 7 additions & 0 deletions src/services/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,16 @@ function getAssetsPublicPath(filePath: string) {
return deepBasePath;
}

function getAssetsRootPath(filePath: string) {
const toc: YfmToc | null = TocService.getForPath(filePath) || null;

return toc?.base;
}

export {
getContentWithUpdatedMetadata,
getContentWithUpdatedStaticMetadata,
getVCSMetadata,
getAssetsPublicPath,
getAssetsRootPath,
};

0 comments on commit 8057b0f

Please sign in to comment.