Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
move versions to Jekyll global variable
Browse files Browse the repository at this point in the history
  • Loading branch information
ys2843 committed May 16, 2020
1 parent d5aecf6 commit 622ddaa
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 41 deletions.
12 changes: 12 additions & 0 deletions docs/static_site/src/_config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ description: >- # this means to ignore newlines until "baseurl:"
twitter_username: apachemxnet
github_username: apache/incubator-mxnet
youtube_username: apachemxnet
default_version: 1.6
versions:
- master
- 1.6
- 1.5.0
- 1.4.1
- 1.3.1
- 1.2.1
- 1.1.0
- 1.0.0
- 0.12.1
- 0.11.0

# Build settings
markdown: kramdown
Expand Down
14 changes: 13 additions & 1 deletion docs/static_site/src/_config_beta.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ url: https://thomasdelteil.github.io
twitter_username: apachemxnet
github_username: apache/incubator-mxnet
youtube_username: apachemxnet

default_version: 1.6
versions:
- master
- 1.6
- 1.5.0
- 1.4.1
- 1.3.1
- 1.2.1
- 1.1.0
- 1.0.0
- 0.12.1
- 0.11.0

# Build settings
markdown: kramdown
plugins:
Expand Down
14 changes: 13 additions & 1 deletion docs/static_site/src/_config_prod.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,19 @@ twitter_username: apachemxnet
github_username: apache/incubator-mxnet
youtube_username: apachemxnet
google_analytics: UA-96378503-1

default_version: 1.6
versions:
- master
- 1.6
- 1.5.0
- 1.4.1
- 1.3.1
- 1.2.1
- 1.1.0
- 1.0.0
- 0.12.1
- 0.11.0

# Build settings
markdown: kramdown
plugins:
Expand Down
22 changes: 19 additions & 3 deletions docs/static_site/src/_includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,20 @@
<input id="global-search" type="text" title="Search" placeholder="Search" />
<div id="global-search-dropdown-container">
<button class="gs-current-version btn" type="button" data-toggle="dropdown">
<span id="gs-current-version-label">1.6</span>
<span id="gs-current-version-label">{{site.default_version}}</span>
<svg class="gs-dropdown-caret" viewBox="0 0 32 32" class="icon icon-caret-bottom" aria-hidden="true">
<path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path>
</svg>
</button>
<ul class="gs-opt-group gs-version-dropdown"></ul>
<ul class="gs-opt-group gs-version-dropdown">
{% for version in site.versions %}
{% if version == site.default_version %}
<li class="gs-opt gs-versions active">{{version}}</li>
{% else %}
<li class="gs-opt gs-versions">{{version}}</li>
{% endif %}
{% endfor %}
</ul>
</div>
<span id="global-search-close">x</span>
</form>
Expand All @@ -61,7 +69,15 @@
<path class="dropdown-caret-path" d="M24 11.305l-7.997 11.39L8 11.305z"></path>
</svg>
</button>
<ul class="gs-opt-group gs-version-dropdown-mobile"></ul>
<ul class="gs-opt-group gs-version-dropdown-mobile">
{% for version in site.versions %}
{% if version == site.default_version %}
<li class="gs-opt gs-versions active">{{version}}</li>
{% else %}
<li class="gs-opt gs-versions">{{version}}</li>
{% endif %}
{% endfor %}
</ul>
</div>
</div>
<a class="page-link" href="{{'/get_started' | relative_url }}">Get Started</a>
Expand Down
39 changes: 3 additions & 36 deletions docs/static_site/src/assets/js/globalSearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,27 +22,14 @@
*/

$(document).ready(function () {
const DEFAULT_CURRENT_VERSION = "1.6";
const VERSIONS = [
"master",
"1.6",
"1.5.0",
"1.4.1",
"1.3.1",
"1.2.1",
"1.1.0",
"1.0.0",
"0.12.1",
"0.11.0",
];

const default_version = $("#gs-current-version-label").text();
// bind docsearch
const globalSearch = docsearch({
apiKey: "500f8e78748bd043cc6e4ac130e8c0e7",
indexName: "apache_mxnet",
inputSelector: "#global-search",
algoliaOptions: {
facetFilters: ["version:" + DEFAULT_CURRENT_VERSION],
facetFilters: ["version:" + default_version],
hitsPerPage: 5,
},
debug: false, // Set debug to true if you want to inspect the dropdown
Expand All @@ -53,32 +40,12 @@ $(document).ready(function () {
indexName: "apache_mxnet",
inputSelector: "#global-search-mobile",
algoliaOptions: {
facetFilters: ["version:" + DEFAULT_CURRENT_VERSION],
facetFilters: ["version:" + default_version],
hitsPerPage: 5,
},
debug: false, // Set debug to true if you want to inspect the dropdown
});

// dynamically generate version dropdown
// to add new version options: edit above constants VERSIONS and DEFAULT_CURRENT_VERSION
$("ul.gs-version-dropdown").append(
VERSIONS.map(function (version) {
const liNode = $("<li>", { class: "gs-opt gs-versions", text: version });
if (version === DEFAULT_CURRENT_VERSION) liNode.addClass("active");
return liNode;
})
);

$("#gs-current-version-label").text(DEFAULT_CURRENT_VERSION);

$("ul.gs-version-dropdown-mobile").append(
VERSIONS.map(function (version) {
const liNode = $("<li>", { class: "gs-opt gs-versions", text: version });
if (version === DEFAULT_CURRENT_VERSION) liNode.addClass("active");
return liNode;
})
);

// search bar animation and event listeners for desktop
$("#gs-search-icon").click(function () {
$(".trigger").fadeOut("fast", function () {
Expand Down

0 comments on commit 622ddaa

Please sign in to comment.