mirror of https://github.com/docker/docs.git
parent
c136b48a5d
commit
888c061228
|
@ -2,7 +2,7 @@
|
|||
{% comment %}
|
||||
"...like all things liquid - where there's a will, and ~36 hours to spare, there's usually a/some way" ~jaybe
|
||||
Usage:
|
||||
{% include toc_pure_liquid.html html=content sanitize=true class="inline_toc" id="my_toc" toc_min=2 toc_max=3 my_name="unnamed" %}
|
||||
{% include toc_pure_liquid.html html=content sanitize=true class="inline_toc" id="my_toc" toc_min=2 toc_max=3 %}
|
||||
|
||||
Variables:
|
||||
* html (string) - the HTML of compiled markdown generated by kramdown in Jekyll
|
||||
|
@ -11,7 +11,6 @@
|
|||
* id (string) - an ID to assigned to the TOC
|
||||
* toc_min (int) - the minimum TOC header level to use (if not set, check page, then site, then default to 2)
|
||||
* toc_max (int) - the maximum TOC header level to use (if not set, check page, then site, then default to 3)
|
||||
* page_name (string) - the URL of the page
|
||||
|
||||
Output:
|
||||
An unordered list representing the table of contents of a markdown block. This snippet will only generate the table of contents and will NOT output the markdown given to it
|
||||
|
@ -20,7 +19,6 @@
|
|||
{% capture my_toc %}{% endcapture %}
|
||||
{% assign minHeader = include.toc_min | default: 2 %}
|
||||
{% assign maxHeader = include.toc_max | default: 3 %}
|
||||
{% assign my_name = include.page_name | default: "unnamed" %}
|
||||
{% assign nodes = include.html | split: '<h' %}
|
||||
|
||||
{% for node in nodes %}
|
||||
|
@ -53,7 +51,7 @@
|
|||
{% endfor %}
|
||||
|
||||
{% capture my_toc %}{{ my_toc }}
|
||||
{{ space }}- [{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}]({{ my_name }}#{{ html_id }}){: class="nomunge" }{% endcapture %}
|
||||
{{ space }}- [{% if include.sanitize %}{{ header | strip_html }}{% else %}{{ header }}{% endif %}](#{{ html_id }}){: class="nomunge" }{% endcapture %}
|
||||
|
||||
{% endfor %}
|
||||
|
||||
|
|
45
js/docs.js
45
js/docs.js
|
@ -161,48 +161,15 @@ function renderNav(docstoc) {
|
|||
|
||||
function highlightRightNav(heading)
|
||||
{
|
||||
if (document.location.pathname.indexOf("/glossary/")<0){
|
||||
//console.log("highlightRightNav called on",document.location.pathname)
|
||||
if (heading == "title")
|
||||
{
|
||||
history.replaceState({},"Top of page on " + document.location.pathname,document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname);
|
||||
$("#my_toc a").each(function(){
|
||||
$(this).removeClass("active");
|
||||
});
|
||||
$("#sidebar-wrapper").animate({
|
||||
scrollTop: 0
|
||||
},800);
|
||||
} else {
|
||||
var targetAnchorHREF = document.location.protocol +"//"+ document.location.hostname + (location.port ? ':'+location.port: '') + document.location.pathname + "#" + heading;
|
||||
// make sure we aren't filtering out that heading level
|
||||
var noFilterFound = false;
|
||||
$("#my_toc a").each(function(){
|
||||
if (this.href==targetAnchorHREF) {
|
||||
noFilterFound = true;
|
||||
}
|
||||
});
|
||||
// now, highlight that heading
|
||||
if (noFilterFound)
|
||||
{
|
||||
$("#my_toc a").each(function(){
|
||||
//console.log("right-nav",this.href);
|
||||
if (this.href==targetAnchorHREF)
|
||||
{
|
||||
history.replaceState({},this.innerText,targetAnchorHREF);
|
||||
$(this).addClass("active");
|
||||
var sidebarOffset = (sidebarBottom > 200) ? 200 : headerOffset - 20;
|
||||
$("#sidebar-wrapper").animate({
|
||||
scrollTop: $("#sidebar-wrapper").scrollTop() + $(this).position().top - sidebarOffset
|
||||
},100);
|
||||
//document.getElementById("sidebar-wrapper").scrollTop = this.getBoundingClientRect().top - 200;
|
||||
} else {
|
||||
$(this).removeClass("active");
|
||||
}
|
||||
});
|
||||
}
|
||||
if (document.location.pathname.indexOf("/glossary/") < 0){
|
||||
$("#my_toc a.active").removeClass("active");
|
||||
|
||||
if (heading !== "title") {
|
||||
$("#my_toc a[href='#" + heading + "']").addClass('active');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var currentHeading = "";
|
||||
$(window).scroll(function(){
|
||||
var headingPositions = new Array();
|
||||
|
|
Loading…
Reference in New Issue