diff options
author | Fabio Berger <me@fabioberger.com> | 2018-02-28 06:29:22 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-02-28 06:29:22 +0800 |
commit | 97fcfb7f6c62aefa3f3a736f7783529d4e3e0018 (patch) | |
tree | 8b7d202ecceb6f467c94c7a4ce95049b5700b88f /packages/website/ts/pages/shared | |
parent | ecba95250d0bfc5b4ab0950ef490a4f262672e6c (diff) | |
download | dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.gz dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.bz2 dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.lz dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.xz dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.zst dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.zip |
Move more configs into docsInfo and remove logic that does not belong there elsewhere
Diffstat (limited to 'packages/website/ts/pages/shared')
-rw-r--r-- | packages/website/ts/pages/shared/nested_sidebar_menu.tsx | 10 | ||||
-rw-r--r-- | packages/website/ts/pages/shared/version_drop_down.tsx | 15 |
2 files changed, 14 insertions, 11 deletions
diff --git a/packages/website/ts/pages/shared/nested_sidebar_menu.tsx b/packages/website/ts/pages/shared/nested_sidebar_menu.tsx index ba794ee9f..1a08ca9f9 100644 --- a/packages/website/ts/pages/shared/nested_sidebar_menu.tsx +++ b/packages/website/ts/pages/shared/nested_sidebar_menu.tsx @@ -16,7 +16,6 @@ interface NestedSidebarMenuProps { onMenuItemClick?: () => void; selectedVersion?: string; versions?: string[]; - docPath?: string; } interface NestedSidebarMenuState {} @@ -69,13 +68,8 @@ export class NestedSidebarMenu extends React.Component<NestedSidebarMenuProps, N <div> {this._renderEmblem()} {!_.isUndefined(this.props.versions) && - !_.isUndefined(this.props.selectedVersion) && - !_.isUndefined(this.props.docPath) && ( - <VersionDropDown - selectedVersion={this.props.selectedVersion} - versions={this.props.versions} - docPath={this.props.docPath} - /> + !_.isUndefined(this.props.selectedVersion) && ( + <VersionDropDown selectedVersion={this.props.selectedVersion} versions={this.props.versions} /> )} <div className="pl1">{navigation}</div> </div> diff --git a/packages/website/ts/pages/shared/version_drop_down.tsx b/packages/website/ts/pages/shared/version_drop_down.tsx index b922e1048..3b331af9b 100644 --- a/packages/website/ts/pages/shared/version_drop_down.tsx +++ b/packages/website/ts/pages/shared/version_drop_down.tsx @@ -6,7 +6,6 @@ import * as React from 'react'; interface VersionDropDownProps { selectedVersion: string; versions: string[]; - docPath: string; } interface VersionDropDownState {} @@ -31,7 +30,17 @@ export class VersionDropDown extends React.Component<VersionDropDownProps, Versi }); return items; } - private _updateSelectedVersion(e: any, index: number, value: string) { - window.location.href = `${this.props.docPath}/${value}${window.location.hash}`; + private _updateSelectedVersion(e: any, index: number, semver: string) { + const port = window.location.port; + const hasPort = !_.isUndefined(port); + let path = window.location.pathname; + const lastChar = path[path.length - 1]; + if (_.isFinite(_.parseInt(lastChar))) { + const pathSections = path.split('/'); + pathSections.pop(); + path = pathSections.join('/'); + } + const baseUrl = `https://${window.location.hostname}${hasPort ? `:${port}` : ''}${path}`; + window.location.href = `${baseUrl}/${semver}${window.location.hash}`; } } |