make toc with goldmark not jquery

This commit is contained in:
zzossig 2020-01-01 20:00:42 +09:00
parent 7e3531f3b7
commit 09a1570af2
8 changed files with 21 additions and 21 deletions

View File

@ -138,6 +138,10 @@ googleAnalytics = ""
lineNos = true
lineNumbersInTable = true
noClasses = false
[markup.tableOfContents]
endLevel = 3
ordered = false
startLevel = 2
[outputs]
home = ["HTML", "RSS", "JSON"]

View File

@ -132,6 +132,10 @@ googleAnalytics = ""
lineNos = true
lineNumbersInTable = true
noClasses = false
[markup.tableOfContents]
endLevel = 3
ordered = false
startLevel = 2
[outputs]
home = ["HTML", "RSS", "JSON"]

View File

@ -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);

View File

@ -96,11 +96,11 @@ $(document).ready(function() {
$('.toc a').removeClass('active');
$('.toc a[href="#' + id + '"]').addClass('active');
$('#toc > li').each(function () {
$('#TableOfContents > ul > li').each(function () {
$(this).find('ul').css('display', 'none');
});
$(`#toc [href="#${id}"]`).next().css('display', 'block');
$(`#toc [href="#${id}"]`).parents('ul').css('display', 'block');
$(`#TableOfContents [href="#${id}"]`).next().css('display', 'block');
$(`#TableOfContents [href="#${id}"]`).parents('ul').css('display', 'block');
}
});
} else { // scroll up
@ -124,11 +124,11 @@ $(document).ready(function() {
$('.toc a').removeClass('active');
$('.toc a[href="#' + id + '"]').addClass('active');
$('#toc > li').each(function () {
$('#TableOfContents > ul > li').each(function () {
$(this).find('ul').css('display', 'none');
});
$(`#toc [href="#${id}"]`).next().css('display', 'block');
$(`#toc [href="#${id}"]`).parents('ul').css('display', 'block');
$(`#TableOfContents [href="#${id}"]`).next().css('display', 'block');
$(`#TableOfContents [href="#${id}"]`).parents('ul').css('display', 'block');
}
});
}

View File

@ -7,7 +7,7 @@
padding-left: 0.5rem;
z-index: z('toc');
#toc {
#TableOfContents {
position: relative;
}

View File

@ -23,11 +23,6 @@
<link rel="stylesheet" href="{{ $photoSwipeSkin.RelPermalink }}">
{{ 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" }}
<script defer src="{{ $js.mermaid.url }}" integrity="{{ $js.mermaid.sri }}" crossorigin="anonymous"></script>
{{ end }}
@ -118,11 +113,10 @@
var hideToc = JSON.parse({{ $hideToc | jsonify }});
if (enableToc || toc) {
$("#toc").toc({ content: ".single__contents", headings: "h1,h2,h3,h4" });
$('#toc > li').each(function () {
$('#TableOfContents > ul > li').each(function () {
$(this).find('ul').css('display', 'none');
});
$('#toc a').each(function () {
$('#TableOfContents a').each(function () {
$(this).click(function () {
navbar.removeClass('navbar--show');
navbar.removeClass('navbar--hide');
@ -133,7 +127,7 @@
});
$(this).addClass('active');
$('#toc > li').each(function () {
$('#TableOfContents > ul > li').each(function () {
$(this).find('ul').css('display', 'none');
});
$(this).next().css('display', 'block');

View File

@ -12,7 +12,7 @@
{{ end }}
</div>
<div class="toc {{ if $.Param "hideToc" }}hide{{ end }}">
<ul id="toc"></ul>
{{ .TableOfContents }}
</div>
</section>