diff --git a/public/index.html b/public/index.html index 8b7f37fb..a9459cce 100755 --- a/public/index.html +++ b/public/index.html @@ -47,6 +47,7 @@ + @@ -60,12 +61,19 @@ hm.src = "https://hm.baidu.com/hm.js?7e2def1fe918f15f9f1c5c061f69b256"; var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(hm, s); + })(); - - function aaa(){ - console.log(111); + 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/UrlTool.js b/src/common/UrlTool.js index 9f7ffe20..98e381e2 100644 --- a/src/common/UrlTool.js +++ b/src/common/UrlTool.js @@ -323,13 +323,13 @@ export function addMeta(name, content){ export function setSeoMeta(keyWords, title, description, url, owner, projectId) { console.log('keyWords:'+ keyWords); document.querySelector(`meta[property='og:title']`).content = title; - document.querySelector(`meta[property='og:url']`).content = location.origin + url; + document.querySelector(`meta[property='og:url']`).content = window.location.origin + url; document.querySelector(`meta[property='og:description']`).content = description + ' - ' + title; document.querySelector(`meta[property='og:image:alt']`).content = description + ' - ' + title; document.querySelector('meta[name="Keywords"]').content=keyWords + 'gitLink,GitLink,gitlink,trustie,trustieforge,forge,开源,确实开源,代码托管,Git,开源,内源,项目管理,版本控制,开源代码,代码分享,项目协作,开源项目托管,免费代码托管,Git代码托管,Git托管服务,确实让创建更美好,协同开发平台'; document.querySelector(`meta[name='description']`).content = description; - document.querySelector(`meta[name='go-import']`).content = location.host + url + ' git ' + location.origin + url; + document.querySelector(`meta[name='go-import']`).content = window.location.host + url + ' git ' + window.location.origin + url; document.querySelector(`meta[name='octolytics-dimension-user_login']`).content = owner; if (projectId) { document.querySelector(`meta[name='octolytics-dimension-repository_nwo']`).content = owner + '/' + projectId; @@ -338,6 +338,6 @@ export function setSeoMeta(keyWords, title, description, url, owner, projectId) document.querySelector(`meta[name='twitter:title']`).content = title; document.querySelector(`meta[name='twitter:description']`).content = description + ' - ' + title; - document.querySelector(`link[rel='canonical']`).href = location.origin + url; + document.querySelector(`link[rel='canonical']`).href = window.location.origin + url; } \ No newline at end of file diff --git a/src/common/marked.js b/src/common/marked.js index 3f27b0a6..22ac47c8 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 = ["