fix: 当前阅读页兼容,及上一页下一页兼容

This commit is contained in:
李亮亮 2024-05-10 10:54:24 +08:00
parent e5073d2809
commit efdcd01e70
3 changed files with 21 additions and 29 deletions

View File

@ -1,6 +1,6 @@
server: server:
port: 8081 port: 8081
dir: dir:
root: \Gitlab\note root: \Work\Github\note-summary
main: PDF main: 专栏
message: <a target="_blank" href='https://www.aliyun.com/minisite/goods?userCode=lc4iupk4'>阿里云2C2G3M 99元/年,老用户也可以哦<a/><hr /> message:

View File

@ -19,18 +19,24 @@ if (path.replace("/", "") === "") {
} }
window.onload = function () { window.onload = function () {
var title = document.title var titleEle = document.getElementById("title");
var ele = document.getElementById(title + ".md"); if (!titleEle) {
if (ele) { return
ele.classList.add("current-tab")
} }
var title = titleEle.getAttribute("data-id")
console.log("title=" + title)
var eleList = document.getElementsByClassName("menu-item") var eleList = document.getElementsByClassName("menu-item")
for (var i = 0; i < eleList.length; i++) { //遍历数组 for (var i = 0; i < eleList.length; i++) { //遍历数组
if (eleList[i].id.startsWith(title) && i > 0) { console.log("eleText=" + eleList[i].id)
document.getElementById("prePage").innerHTML = "<a href='" + eleList[i - 1].getAttribute("href") + "'>上一页</a>" if (eleList[i].id.startsWith(title)) {
} eleList[i].classList.add("current-tab")
if (eleList[i].id.startsWith(title) && i < eleList.length) { if (i > 0) {
document.getElementById("nextPage").innerHTML = "<a href='" + eleList[i + 1].getAttribute("href") + "'>下一页</a>" document.getElementById("prePage").innerHTML = "<a href='" + eleList[i - 1].getAttribute("href") + "'>上一页</a>"
}
if (i < eleList.length) {
document.getElementById("nextPage").innerHTML = "<a href='" + eleList[i + 1].getAttribute("href") + "'>下一页</a>"
}
} }
} }
} }
@ -92,15 +98,3 @@ function hide_canvas() {
sidebar.classList.remove('show') sidebar.classList.remove('show')
overlay.classList.remove('show') overlay.classList.remove('show')
} }
const gitalk = new Gitalk({
clientID: 'a0fe07089fe55e24df4e',
clientSecret: '58bc23313fbc2e117a34f024967b6b3caaffc1e9',
repo: 'com-lianglianglee-learn', // The repository of store comments,
owner: 'lianglianglee-learn',
admin: ['lianglianglee-learn'],
id: document.title, // Ensure uniqueness and length less than 50
distractionFreeMode: false // Facebook-like distraction free mode
})
gitalk.render('gitalk-container')

View File

@ -18,8 +18,6 @@
<meta name="generator" content="Hexo 4.2.0"> <meta name="generator" content="Hexo 4.2.0">
<script async defer data-website-id="83e5d5db-9d06-40e3-b780-cbae722fdf8c" <script async defer data-website-id="83e5d5db-9d06-40e3-b780-cbae722fdf8c"
src="http://analyze.lianglianglee.com/umami.js"></script> src="http://analyze.lianglianglee.com/umami.js"></script>
<link rel="stylesheet" href="https://unpkg.com/gitalk/dist/gitalk.css">
<script src="https://unpkg.com/gitalk/dist/gitalk.min.js"></script>
</head> </head>
<body> <body>
@ -68,9 +66,11 @@
overflow-x: auto; overflow-x: auto;
overflow-y: hidden;"> overflow-y: hidden;">
<div class="book-post"> <div class="book-post">
{{if .message}}
<div align="center">{{.message}}</div> <div align="center">{{.message}}</div>
{{end}}
<p id="tip" align="center"></p> <p id="tip" align="center"></p>
<p class="title">{{.title}}</p> <h1 id="title" data-id="{{.title}}" class="title">{{.title}}</h1>
<div>{{ .htmlContext }}</div> <div>{{ .htmlContext }}</div>
</div> </div>
<div> <div>
@ -82,8 +82,6 @@
</div> </div>
</div> </div>
<div id="gitalk-container"></div>
</div> </div>
</div> </div>
</div> </div>