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

View File

@ -19,18 +19,24 @@ if (path.replace("/", "") === "") {
}
window.onload = function () {
var title = document.title
var ele = document.getElementById(title + ".md");
if (ele) {
ele.classList.add("current-tab")
var titleEle = document.getElementById("title");
if (!titleEle) {
return
}
var title = titleEle.getAttribute("data-id")
console.log("title=" + title)
var eleList = document.getElementsByClassName("menu-item")
for (var i = 0; i < eleList.length; i++) { //遍历数组
if (eleList[i].id.startsWith(title) && i > 0) {
document.getElementById("prePage").innerHTML = "<a href='" + eleList[i - 1].getAttribute("href") + "'>上一页</a>"
}
if (eleList[i].id.startsWith(title) && i < eleList.length) {
document.getElementById("nextPage").innerHTML = "<a href='" + eleList[i + 1].getAttribute("href") + "'>下一页</a>"
console.log("eleText=" + eleList[i].id)
if (eleList[i].id.startsWith(title)) {
eleList[i].classList.add("current-tab")
if (i > 0) {
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')
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">
<script async defer data-website-id="83e5d5db-9d06-40e3-b780-cbae722fdf8c"
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>
<body>
@ -68,9 +66,11 @@
overflow-x: auto;
overflow-y: hidden;">
<div class="book-post">
{{if .message}}
<div align="center">{{.message}}</div>
{{end}}
<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>
<div>
@ -82,8 +82,6 @@
</div>
</div>
<div id="gitalk-container"></div>
</div>
</div>
</div>