diff --git a/Makefile b/Makefile
index bfd86f727..1b5bb00dd 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,12 @@ CONTAINER_RUN_CMD ?= docker run
# same site url than the "host" it binds to. Thus, all the links will be
# broken if we'd bind to 0.0.0.0
JEKYLL_VERSION := 3.8
-SITE_BUILD_CMD := $(CONTAINER_RUN_CMD) --rm -i -u "`id -u`:`id -g`" --volume="$$PWD/docs:/srv/jekyll" --volume="$$PWD/docs/vendor/bundle:/usr/local/bundle" --network=host jekyll/jekyll:$(JEKYLL_VERSION)
+JEKYLL_ENV ?= development
+SITE_BUILD_CMD := $(CONTAINER_RUN_CMD) --rm -i -u "`id -u`:`id -g`" \
+ -e JEKYLL_ENV=$(JEKYLL_ENV) \
+ --volume="$$PWD/docs:/srv/jekyll" \
+ --volume="$$PWD/docs/vendor/bundle:/usr/local/bundle" \
+ --network=host jekyll/jekyll:$(JEKYLL_VERSION)
SITE_SUBDIR ?=
JEKYLL_OPTS := -d _site/$(SITE_SUBDIR) -b /node-feature-discovery/$(SITE_SUBDIR)
diff --git a/docs/_config.yml b/docs/_config.yml
index d76b4ebd9..76b9befdf 100644
--- a/docs/_config.yml
+++ b/docs/_config.yml
@@ -40,10 +40,6 @@ remote_theme: rundocs/jekyll-rtd-theme@v2.0.9
# - vendor/gems/
# - vendor/ruby/
-# Document versioning. Current 'version' should be listed under
-# 'versions' as we use it in constructing the baseurl for other
-# versions.
+# Document versioning
version: v0.6
-versions:
- - master
- - v0.6
+display_version_list: true
diff --git a/docs/_includes/class/addons-wrap.liquid b/docs/_includes/class/addons-wrap.liquid
index 8385205dc..993d4cb52 100644
--- a/docs/_includes/class/addons-wrap.liquid
+++ b/docs/_includes/class/addons-wrap.liquid
@@ -1,51 +1,58 @@
-
-
- - Versions:
-
- {% comment %}
- The following ugly construction is solely for the
- purpose of dropping the "version" suffix from the
- baseurl. The reason for doing this is that github-pages
- gem forces us on --safe mode (i.e. disables custom
- plugins) so we're not able to write a simple ruby
- plugin doing delete_suffix()
- {% endcomment %}
- {% assign version_len = site.version | size %}
- {% assign baseurl_len = site.baseurl | size %}
- {% assign idx = baseurl_len | minus: version_len %}
- {% assign suffix = site.baseurl | slice: idx, version_len %}
- {% if suffix == site.version %}
- {% assign idx = idx | minus: 1 %}
- {% assign baseurl = site.baseurl | slice: 0, idx %}
- {% else %}
- {% assign baseurl = site.baseurl %}
- {% endif %}
-
- {% for version in site.versions %}
- - {{ version }}
- {% endfor %}
-
-
{{ site.title }}
+
+ {{ site.version }}
+
+ {% if site.display_version_list %}
+
+ - Versions
+
+ {% if jekyll.environment == "development" %}
+ -
+ {{ site.version }}
+
+ {% else %}
+ {% comment %}
+ Drop the last component from site.baseurl which is supposed to
+ be pointing to a subdirectory of the true site baseurl.
+ {% endcomment %}
+ {% assign spliturl = site.baseurl | split: "/" %}
+ {% assign last = spliturl.size | minus: 1 %}
+ {% assign baseurl = spliturl | slice: 0, last | join: "/" %}
+
+
+
+ {% endif %}
+
+ {% endif %}
{%- assign items = "github" | split: ", " -%}
{% for item in items -%}
{% include addons/{{ item }}.liquid %}
{% endfor -%}
-
diff --git a/scripts/github/update-gh-pages.sh b/scripts/github/update-gh-pages.sh
index eb08383b3..f505d5335 100755
--- a/scripts/github/update-gh-pages.sh
+++ b/scripts/github/update-gh-pages.sh
@@ -14,6 +14,19 @@ Options:
EOF
}
+# Helper function for detecting available versions from the current directory
+create_versions_js() {
+ local _baseurl="/node-feature-discovery"
+
+ echo -e "function getVersionListItems() {\n return ["
+ # 'stable' is a symlink pointing to the latest version
+ [ -f stable ] && echo " { name: 'stable', url: '$_baseurl/stable' },"
+ for f in `ls -d */ | tr -d /` ; do
+ echo " { name: '$f', url: '$_baseurl/$f' },"
+ done
+ echo -e " ];\n}"
+}
+
#
# Argument parsing
#
@@ -89,6 +102,7 @@ fi
export SITE_SUBDIR=${site_subdir:-master}
echo "Updating site subdir: '$SITE_SUBDIR'"
+export JEKYLL_ENV=production
make site-build
#
@@ -103,6 +117,12 @@ fi
# Switch to work in the gh-pages worktree
cd "$build_dir"
+_stable=`(ls -d1 v*/ || :) | sort -n | tail -n1`
+[ -n "$_stable" ] && ln -sfT "$_stable" stable
+
+# Detect existing versions from the gh-pages branch
+create_versions_js > versions.js
+
if [ -z "`git status --short`" ]; then
echo "No new content, gh-pages branch already up-to-date"
exit 0
diff --git a/scripts/test-infra/build-gh-pages.sh b/scripts/test-infra/build-gh-pages.sh
index c62571c8c..942ff45f8 100755
--- a/scripts/test-infra/build-gh-pages.sh
+++ b/scripts/test-infra/build-gh-pages.sh
@@ -8,4 +8,4 @@ mkdir -p "$_outdir"
chmod a+rwx "$_outdir"
# Build docs
-make site-build
+JEKYLL_ENV=production make site-build