mirror of https://github.com/docker/docs.git
Fix for anchor links
This commit is contained in:
parent
774581c998
commit
56940587a8
|
@ -77,8 +77,29 @@ else %}{% assign edit_url = "" %}{% endif %} {% break %} {% endif %} {% endfor %
|
|||
<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>●</span> {% endif %}
|
||||
|
|
19
js/docs.js
19
js/docs.js
|
@ -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]) {
|
||||
|
|
Loading…
Reference in New Issue