make toc with goldmark not jquery
This commit is contained in:
parent
7e3531f3b7
commit
09a1570af2
|
@ -138,6 +138,10 @@ googleAnalytics = ""
|
||||||
lineNos = true
|
lineNos = true
|
||||||
lineNumbersInTable = true
|
lineNumbersInTable = true
|
||||||
noClasses = false
|
noClasses = false
|
||||||
|
[markup.tableOfContents]
|
||||||
|
endLevel = 3
|
||||||
|
ordered = false
|
||||||
|
startLevel = 2
|
||||||
|
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["HTML", "RSS", "JSON"]
|
home = ["HTML", "RSS", "JSON"]
|
||||||
|
|
|
@ -132,6 +132,10 @@ googleAnalytics = ""
|
||||||
lineNos = true
|
lineNos = true
|
||||||
lineNumbersInTable = true
|
lineNumbersInTable = true
|
||||||
noClasses = false
|
noClasses = false
|
||||||
|
[markup.tableOfContents]
|
||||||
|
endLevel = 3
|
||||||
|
ordered = false
|
||||||
|
startLevel = 2
|
||||||
|
|
||||||
[outputs]
|
[outputs]
|
||||||
home = ["HTML", "RSS", "JSON"]
|
home = ["HTML", "RSS", "JSON"]
|
||||||
|
|
|
@ -1,2 +0,0 @@
|
||||||
/*! Table of Contents jQuery Plugin - jquery.toc * Copyright (c) 2013-2016 Nikhil Dabas * http://www.apache.org/licenses/LICENSE-2.0 */
|
|
||||||
!function(a){"use strict";var b=function(b){return this.each(function(){var c,d,e=a(this),f=e.data(),g=[e],h=this.tagName,i=0;c=a.extend({content:"body",headings:"h1,h2,h3"},{content:f.toc||void 0,headings:f.tocHeadings||void 0},b),d=c.headings.split(","),a(c.content).find(c.headings).attr("id",function(b,c){var d=function(a){0===a.length&&(a="?");for(var b=a.replace(/\s+/g,"_"),c="",d=1;null!==document.getElementById(b+c);)c="_"+d++;return b+c};return c||d(a(this).text())}).each(function(){var b=a(this),c=a.map(d,function(a,c){return b.is(a)?c:void 0})[0];if(c>i){var e=g[0].children("li:last")[0];e&&g.unshift(a("<"+h+"/>").appendTo(e))}else g.splice(0,Math.min(i-c,Math.max(g.length-1,0)));a("<li/>").appendTo(g[0]).append(a("<a/>").text(b.text()).attr("href","#"+b.attr("id"))),i=c})})},c=a.fn.toc;a.fn.toc=b,a.fn.toc.noConflict=function(){return a.fn.toc=c,this},a(function(){b.call(a("[data-toc]"))})}(window.jQuery);
|
|
|
@ -96,11 +96,11 @@ $(document).ready(function() {
|
||||||
$('.toc a').removeClass('active');
|
$('.toc a').removeClass('active');
|
||||||
$('.toc a[href="#' + id + '"]').addClass('active');
|
$('.toc a[href="#' + id + '"]').addClass('active');
|
||||||
|
|
||||||
$('#toc > li').each(function () {
|
$('#TableOfContents > ul > li').each(function () {
|
||||||
$(this).find('ul').css('display', 'none');
|
$(this).find('ul').css('display', 'none');
|
||||||
});
|
});
|
||||||
$(`#toc [href="#${id}"]`).next().css('display', 'block');
|
$(`#TableOfContents [href="#${id}"]`).next().css('display', 'block');
|
||||||
$(`#toc [href="#${id}"]`).parents('ul').css('display', 'block');
|
$(`#TableOfContents [href="#${id}"]`).parents('ul').css('display', 'block');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} else { // scroll up
|
} else { // scroll up
|
||||||
|
@ -124,11 +124,11 @@ $(document).ready(function() {
|
||||||
$('.toc a').removeClass('active');
|
$('.toc a').removeClass('active');
|
||||||
$('.toc a[href="#' + id + '"]').addClass('active');
|
$('.toc a[href="#' + id + '"]').addClass('active');
|
||||||
|
|
||||||
$('#toc > li').each(function () {
|
$('#TableOfContents > ul > li').each(function () {
|
||||||
$(this).find('ul').css('display', 'none');
|
$(this).find('ul').css('display', 'none');
|
||||||
});
|
});
|
||||||
$(`#toc [href="#${id}"]`).next().css('display', 'block');
|
$(`#TableOfContents [href="#${id}"]`).next().css('display', 'block');
|
||||||
$(`#toc [href="#${id}"]`).parents('ul').css('display', 'block');
|
$(`#TableOfContents [href="#${id}"]`).parents('ul').css('display', 'block');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
padding-left: 0.5rem;
|
padding-left: 0.5rem;
|
||||||
z-index: z('toc');
|
z-index: z('toc');
|
||||||
|
|
||||||
#toc {
|
#TableOfContents {
|
||||||
position: relative;
|
position: relative;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -23,11 +23,6 @@
|
||||||
<link rel="stylesheet" href="{{ $photoSwipeSkin.RelPermalink }}">
|
<link rel="stylesheet" href="{{ $photoSwipeSkin.RelPermalink }}">
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
{{ if or ($.Param "enableToc") ($.Param "toc") }}
|
|
||||||
{{ $toc := resources.Get "js/jquery.toc.min.js" | resources.Fingerprint }}
|
|
||||||
<script defer src="{{ $toc.RelPermalink }}"></script>
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
{{ if in .Params.Libraries "mermaid" }}
|
{{ if in .Params.Libraries "mermaid" }}
|
||||||
<script defer src="{{ $js.mermaid.url }}" integrity="{{ $js.mermaid.sri }}" crossorigin="anonymous"></script>
|
<script defer src="{{ $js.mermaid.url }}" integrity="{{ $js.mermaid.sri }}" crossorigin="anonymous"></script>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
@ -118,11 +113,10 @@
|
||||||
var hideToc = JSON.parse({{ $hideToc | jsonify }});
|
var hideToc = JSON.parse({{ $hideToc | jsonify }});
|
||||||
|
|
||||||
if (enableToc || toc) {
|
if (enableToc || toc) {
|
||||||
$("#toc").toc({ content: ".single__contents", headings: "h1,h2,h3,h4" });
|
$('#TableOfContents > ul > li').each(function () {
|
||||||
$('#toc > li').each(function () {
|
|
||||||
$(this).find('ul').css('display', 'none');
|
$(this).find('ul').css('display', 'none');
|
||||||
});
|
});
|
||||||
$('#toc a').each(function () {
|
$('#TableOfContents a').each(function () {
|
||||||
$(this).click(function () {
|
$(this).click(function () {
|
||||||
navbar.removeClass('navbar--show');
|
navbar.removeClass('navbar--show');
|
||||||
navbar.removeClass('navbar--hide');
|
navbar.removeClass('navbar--hide');
|
||||||
|
@ -133,7 +127,7 @@
|
||||||
});
|
});
|
||||||
$(this).addClass('active');
|
$(this).addClass('active');
|
||||||
|
|
||||||
$('#toc > li').each(function () {
|
$('#TableOfContents > ul > li').each(function () {
|
||||||
$(this).find('ul').css('display', 'none');
|
$(this).find('ul').css('display', 'none');
|
||||||
});
|
});
|
||||||
$(this).next().css('display', 'block');
|
$(this).next().css('display', 'block');
|
||||||
|
@ -155,7 +149,7 @@
|
||||||
$('.toc__flexbox').attr('data-position', 'absolute');
|
$('.toc__flexbox').attr('data-position', 'absolute');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add link button for every
|
// Add link button for every
|
||||||
var text, clip = new ClipboardJS('.anchor');
|
var text, clip = new ClipboardJS('.anchor');
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<div class="toc {{ if $.Param "hideToc" }}hide{{ end }}">
|
<div class="toc {{ if $.Param "hideToc" }}hide{{ end }}">
|
||||||
<ul id="toc"></ul>
|
{{ .TableOfContents }}
|
||||||
</div>
|
</div>
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue