Merge pull request #547 from AMoo-Miki/allow-latest-1.3
Allow `latest` version not to be the `current` version of the docs
This commit is contained in:
commit
07b1adc3e0
|
@ -1,8 +1,11 @@
|
|||
{
|
||||
"current": "1.3",
|
||||
"past": [
|
||||
"all": [
|
||||
"2.0",
|
||||
"1.3",
|
||||
"1.2",
|
||||
"1.1",
|
||||
"1.0"
|
||||
]
|
||||
}
|
||||
],
|
||||
"latest": "1.3"
|
||||
}
|
|
@ -57,7 +57,6 @@ layout: table_wrappers
|
|||
</a>
|
||||
</div>
|
||||
<nav role="navigation" aria-label="Main" id="site-nav" class="site-nav">
|
||||
{% assign past_versions = site.data.versions.past | join: ";" %}
|
||||
<div class="version-wrapper">
|
||||
<version-selector selected="{{ site.data.versions.current }}"></version-selector>
|
||||
</div>
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
/* During build, DOC_VERSIONS is prefixed to convey all the versions available, informed by `_data/versions.json`
|
||||
* Example:
|
||||
* const DOC_VERSIONS = ["1.1","1.0"];
|
||||
*
|
||||
* DOC_VERSION_LATEST will pick `latest`, or in its absence the `current` version.
|
||||
* const DOC_VERSION_LATEST = "2.0";
|
||||
*/
|
||||
const PREFIX = "OpenSearch ";
|
||||
const tpl = `
|
||||
|
@ -155,7 +158,7 @@ class VersionSelector extends HTMLElement {
|
|||
frag.querySelector('#selected').textContent = `${PREFIX}${this.getAttribute('selected')}.x`;
|
||||
|
||||
const pathName = location.pathname.replace(/\/docs(\/((latest|\d+\.\d+)\/?)?)?/, '');
|
||||
const versionsDOMText = DOC_VERSIONS.map((v, idx) => `<a href="/docs/${v}/${pathName}"${idx === 0 ? ' class="latest"' : ''}>${PREFIX}${v}.x</a>`)
|
||||
const versionsDOMText = DOC_VERSIONS.map((v, idx) => `<a href="/docs/${v}/${pathName}"${v === DOC_VERSION_LATEST ? ' class="latest"' : ''}>${PREFIX}${v}.x</a>`)
|
||||
.join('');
|
||||
|
||||
frag.querySelector('#dropdown').appendChild(this._makeFragment(versionsDOMText));
|
||||
|
|
|
@ -2,8 +2,17 @@
|
|||
permalink: /assets/js/version-selector.js
|
||||
---
|
||||
(() => {
|
||||
{% assign current_array = site.data.versions.current | split: '!' %}
|
||||
{% assign all_versions = current_array | concat: site.data.versions.past %}
|
||||
{% if site.data.versions.all contains site.data.versions.current %}
|
||||
{% assign all_versions = site.data.versions.all %}
|
||||
{% else %}
|
||||
{% assign current_array = site.data.versions.all | split: '!' %}
|
||||
{% assign all_versions = current_array | concat: site.data.versions.all %}
|
||||
{% endif %}
|
||||
const DOC_VERSIONS = {{ all_versions | jsonify }};
|
||||
{% if site.data.versions.latest %}
|
||||
const DOC_VERSION_LATEST = {{ site.data.versions.latest | jsonify }};
|
||||
{% else %}
|
||||
const DOC_VERSION_LATEST = {{ site.data.versions.current | jsonify }};
|
||||
{% endif %}
|
||||
{% include_relative _version-selector.js %}
|
||||
})();
|
Loading…
Reference in New Issue