Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Create new partial to display links to the Nightly and LTS release. - Disable breadcrumb and use that space for the links.
- Loading branch information
1 parent
24ec4c9
commit 17ee7b8
Showing
9 changed files
with
96 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{{ $jsRelSwitcher := resources.Get "js/release-switcher.js" }} | ||
{{ $jsRelSwitcher := $jsRelSwitcher | fingerprint }} | ||
<script src="{{ $jsRelSwitcher.RelPermalink }}" integrity="{{ $jsRelSwitcher.Data.Integrity }}"></script> | ||
<nav class="td-breadcrumbs td-breadcrumbs__single" id="release-switcher"> | ||
<ol class="breadcrumb font-weight-bold"> | ||
<li id="latest-release-li" class="breadcrumb-item active"> | ||
Documentation for latest release | ||
</li> | ||
|
||
<li id="nightly-release-li" class="breadcrumb-item"> | ||
<a id="nightly-release-link" href="#">Go to Nightly Release</a> | ||
</li> | ||
|
||
<li id="lts-release-li" class="breadcrumb-item"> | ||
<a id="lts-release-link" href="#">Go to Latest LTS release</a> | ||
</li> | ||
</ol> | ||
<script>findReleases()</script> | ||
</nav> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
if (typeof componentVersions === 'undefined') { | ||
const componentVersions = JSON.parse('{{ component_versions_json }}'); | ||
} | ||
|
||
const getComponentReleases = () => { | ||
const pathName = window.location.pathname; | ||
const componentVersionStr = pathName.split("/")[2]; | ||
const componentRawName = componentVersionStr.split("-")[0]; | ||
let latestVersion; | ||
let nightlyVersion; | ||
let latestLTS; | ||
let componentName; | ||
|
||
componentVersions.forEach((componentVersion) => { | ||
if (componentVersion.name.toLowerCase() === componentRawName) { | ||
componentName = componentVersion.name; | ||
const versions = componentVersion.tags; | ||
latestVersion = versions[0].displayName; | ||
if (versions.length > 1) { | ||
nightlyVersion = versions[versions.length - 1].displayName; | ||
} | ||
versions.forEach((version) => { | ||
if (version.displayName.toLowerCase().includes('lts') && !latestLTS) { | ||
latestLTS = version.displayName; | ||
} | ||
}); | ||
} | ||
}); | ||
return { | ||
name: componentName, | ||
latest: latestVersion, | ||
nightly: nightlyVersion, | ||
lts: latestLTS, | ||
}; | ||
}; | ||
|
||
const findReleases = () => { | ||
const componentReleases = getComponentReleases(); | ||
|
||
const releasesNode = document.getElementById('release-switcher'); | ||
const latestNode = document.getElementById('latest-release-li'); | ||
const nightlyLiNode = document.getElementById('nightly-release-li'); | ||
const nightlyNode = document.getElementById('nightly-release-link'); | ||
const ltsLiNode = document.getElementById('lts-release-li'); | ||
const ltsNode = document.getElementById('lts-release-link'); | ||
|
||
if (componentReleases.name) { | ||
let nightlyURL = `/vault/${componentReleases.name}-${componentReleases.nightly}`; | ||
let ltsURL = `/vault/${componentReleases.name}-${componentReleases.lts}`; | ||
releasesNode.style.visibility = 'visible'; | ||
latestNode.innerText = `Documentation for ${componentReleases.name}-${componentReleases.latest}`; | ||
if (componentReleases.nightly) { | ||
nightlyLiNode.style.visibility = 'visible'; | ||
nightlyNode.setAttribute('href', nightlyURL.toLowerCase()); | ||
} | ||
if (componentReleases.lts) { | ||
ltsLiNode.style.visibility = 'visible'; | ||
ltsURL = (componentReleases.lts == componentReleases.latest) ? '#' : ltsURL.toLowerCase(); | ||
ltsNode.setAttribute('href', ltsURL); | ||
} | ||
} | ||
}; |