Skip to content

Commit

Permalink
Fix for anchor links
Browse files Browse the repository at this point in the history
  • Loading branch information
johndmulhausen committed Mar 2, 2017
1 parent 774581c commit 5694058
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 21 deletions.
25 changes: 23 additions & 2 deletions _layouts/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,29 @@
<section class="section">
{% if page.title %}
<h1>{{ page.title }}</h1>{% endif %} {% if page.advisory %}
<blockquote>{{ site.data.advisories.texts[page.advisory] | markdownify }}</blockquote>{% endif %} {% unless page.tree == false %}{% include read_time.html %}{% endunless %} {{ content }} {% if page.noratings != true %}
<div style="text-align: center; margin-top: 50px">
<blockquote>{{ site.data.advisories.texts[page.advisory] | markdownify }}</blockquote>{% endif %} {% unless page.tree == false %}{% include read_time.html %}{% endunless %}{{ content }}
<script language="JavaScript">
var x = document.links.length;
var baseHref = document.getElementsByTagName('base')[0].href
for (i = 0; i < x; i++) {
var munged = false;
var thisHREF = document.links[i].href;
var originalURL = "{{ page.url }}";
if (thisHREF.indexOf(baseHref + "#") > -1) {
// hash fix
//console.log('BEFORE: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
thisHREF = originalURL + thisHREF.replace(baseHref, "");
//console.log('AFTER: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
}
if ((thisHREF.indexOf(window.location.hostname) > -1 || thisHREF.indexOf('http') == -1) && document.links[i].className.indexOf("nomunge") < 0) {
munged = true;
thisHREF = thisHREF.replace(".md", "/").replace("/index/", "/");
document.links[i].setAttribute('href', thisHREF);
}
}
</script>
{% if page.noratings != true %}
<div style="text-align: center; margin-top: 50px">
<img src="/images/chat.png" alt="chat icon" style="display:inline">
<b>Feedback?</b> Suggestions? Can't find something in the docs?<br/> {% if edit_url != "" %}
<a href="https://github.com/docker/docker.github.io/edit/master/{{ page.path }}" class="nomunge">Edit this page</a> <span>&#9679;</span> {% endif %}
Expand Down
19 changes: 0 additions & 19 deletions js/docs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,6 @@ var sidebarBottom = sidebarObj.getBoundingClientRect().bottom;
var footerTop = document.getElementsByClassName("footer")[0].getBoundingClientRect().top;
var headerOffset = document.getElementsByClassName("container-fluid")[0].getBoundingClientRect().bottom;

var x = document.links.length;
var baseHref = document.getElementsByTagName('base')[0].href
for (i = 0; i < x; i++) {
var munged = false;
var thisHREF = document.links[i].href;
var originalURL = "{{ page.url }}";
if (thisHREF.indexOf(baseHref + "#") > -1) {
// hash fix
//console.log('BEFORE: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
thisHREF = originalURL + thisHREF.replace(baseHref, "");
//console.log('AFTER: base:',baseHref,'thisHREF:',thisHREF,'originalURL:',originalURL);
}
if ((thisHREF.indexOf(window.location.hostname) > -1 || thisHREF.indexOf('http') == -1) && document.links[i].className.indexOf("nomunge") < 0) {
munged = true;
thisHREF = thisHREF.replace(".md", "/").replace("/index/", "/");
document.links[i].setAttribute('href', thisHREF);
}
}

// ensure that the left nav visibly displays the current topic
var current = document.getElementsByClassName("active currentPage");
if (current[0]) {
Expand Down

0 comments on commit 5694058

Please sign in to comment.