Repository: cordova-docs Updated Branches: refs/heads/master ceffd6484 -> 2dea8baba
CB-10028: Made docs toc links relative to URL. This closes #425. Project: http://git-wip-us.apache.org/repos/asf/cordova-docs/repo Commit: http://git-wip-us.apache.org/repos/asf/cordova-docs/commit/2dea8bab Tree: http://git-wip-us.apache.org/repos/asf/cordova-docs/tree/2dea8bab Diff: http://git-wip-us.apache.org/repos/asf/cordova-docs/diff/2dea8bab Branch: refs/heads/master Commit: 2dea8baba9ef30074d275d14687df40e0faa6988 Parents: ceffd64 Author: riknoll <[email protected]> Authored: Tue Nov 17 14:45:25 2015 -0800 Committer: Dmitry Blotsky <[email protected]> Committed: Wed Nov 18 19:55:51 2015 -0800 ---------------------------------------------------------------------- www/_layouts/docs.html | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/cordova-docs/blob/2dea8bab/www/_layouts/docs.html ---------------------------------------------------------------------- diff --git a/www/_layouts/docs.html b/www/_layouts/docs.html index c273711..4c27a03 100644 --- a/www/_layouts/docs.html +++ b/www/_layouts/docs.html @@ -12,6 +12,16 @@ analytics_id: UA-64283057-1 {% assign tocfile = toc_dir.[page.generated_toc] %} {% endif %} +{% comment %} + <!-- We want TOC links to be relative in order to make sure we preserve aliases + like "latest" in the URL. The captures are both horrendous single line + statements in order to prevent the capturing of extra whitespace. --> +{% endcomment %} + +{% assign url_split = page.url | split: "/" %} +{% capture relative_base_path %}{% for item in url_split %}{% if forloop.index0 > 3 and forloop.rindex > 1 %}../{% endif %}{% endfor %}{% endcapture %} +{% capture actual_base_path %}{% for item in url_split %}{% if forloop.index0 < 4 and forloop.index0 != 0 %}/{{item}}{% endif %}{% endfor %}/{% endcapture %} + <div class="docs container"> <!-- Table of Contents --> @@ -20,7 +30,7 @@ analytics_id: UA-64283057-1 <ul class="site-toc"> {% for entry in tocfile %} <li> - <a class="{% if page.url == entry.url %}this-page{% endif %}" href="{{ site.baseurl }}{{ entry.url }}"> + <a class="{% if page.url == entry.url %}this-page{% endif %}" href="{{ entry.url | replace:actual_base_path,relative_base_path }}"> {{ entry.name }} </a> {% if page.url == entry.url %} @@ -44,7 +54,7 @@ analytics_id: UA-64283057-1 <ul class="dropdown-menu"> {% for entry in tocfile %} <li> - <a class="{% if page.url == entry.url %}this-page{% endif %}" href="{{ site.baseurl }}{{ entry.url }}"> + <a class="{% if page.url == entry.url %}this-page{% endif %}" href="{{ entry.url | replace:actual_base_path,relative_base_path }}"> {% if page.url == entry.url %} <em>{{ entry.name }}</em> {% else %} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
