added basePath to markdown components in order to allow navigation between md files

This commit is contained in:
Sebastian Sdorra
2020-05-19 15:52:11 +02:00
parent d1f10ec5a7
commit ffd04eb55b
3 changed files with 22 additions and 12 deletions

View File

@@ -76,13 +76,19 @@ class SourcesView extends React.Component<Props, State> {
});
}
createBasePath() {
const { repository, revision } = this.props;
return `/repo/${repository.namespace}/${repository.name}/code/sources/${revision}/`;
}
showSources() {
const { file, revision } = this.props;
const { contentType, language } = this.state;
const basePath = this.createBasePath();
if (contentType.startsWith("image/")) {
return <ImageViewer file={file} />;
} else if (contentType.includes("markdown")) {
return <SwitchableMarkdownViewer file={file} />;
return <SwitchableMarkdownViewer file={file} basePath={basePath} />;
} else if (language) {
return <SourcecodeViewer file={file} language={language} />;
} else if (contentType.startsWith("text/")) {
@@ -94,7 +100,8 @@ class SourcesView extends React.Component<Props, State> {
props={{
file,
contentType,
revision
revision,
basePath
}}
>
<DownloadViewer file={file} />