diff --git a/public/index.html b/public/index.html index 6c674f7cd..4eada4459 100755 --- a/public/index.html +++ b/public/index.html @@ -32,6 +32,7 @@ + @@ -45,8 +46,19 @@ hm.src = "https://hm.baidu.com/hm.js?7e2def1fe918f15f9f1c5c061f69b256"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); + })(); - + window.onload=function(){ + $(".newContainer").delegate("a.anchors","click",function(){ + let h = $(this).offset().top - 180; + console.log($(this).offset().top,document.body.scrollTop); + $("html,body").animate({scrollTop:h},10); + window.location.hash = $(this).attr("name"); + return false; + }); + } + + \ No newline at end of file diff --git a/src/common/marked.js b/src/common/marked.js index 3f27b0a6f..22ac47c85 100644 --- a/src/common/marked.js +++ b/src/common/marked.js @@ -23,6 +23,7 @@ function indentCodeCompensation(raw, text) { .join('\n'); } + //兼容之前的 ##标题式写法 let toc = [] let ctx = ["