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/version_drop_down.tsx | |
parent | ecba95250d0bfc5b4ab0950ef490a4f262672e6c (diff) | |
download | dexon-sol-tools-97fcfb7f6c62aefa3f3a736f7783529d4e3e0018.tar.gz 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/version_drop_down.tsx')
-rw-r--r-- | packages/website/ts/pages/shared/version_drop_down.tsx | 15 |
1 files changed, 12 insertions, 3 deletions
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}`; } } |