-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
337a435
commit dc5c8af
Showing
34 changed files
with
527 additions
and
44 deletions.
There are no files selected for viewing
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,3 +26,6 @@ theme = "m10c" | |
|
||
[params.style] | ||
primaryColor = "#87CEFA" | ||
|
||
[params] | ||
customCSS = ["css/custom.css"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
public/css/main.min.08e876a0f4aeb92fb7ca4e4c12d7d6ea16684353b267ad3f4385e180cc91a06b.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
public/css/main.min.1b0bf2b31cb0f514c537ceb35ddbd58adbdcbcc1d430e6d4a1f0384df4d59832.css
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
// 等待 DOM 加载完成 | ||
document.addEventListener('DOMContentLoaded', function () { | ||
const tocToggle = document.getElementById('toc-toggle'); | ||
const tocContainer = document.getElementById('toc'); | ||
const contentArea = document.querySelector('.post-content'); // 根据你的内容区域的类名调整 | ||
|
||
// 生成目录函数 | ||
function generateTOC() { | ||
const headings = contentArea.querySelectorAll('h1, h2, h3'); | ||
console.log("Headings found:", headings); // 输出找到的标题元素 | ||
if (headings.length === 0) { | ||
// 如果没有找到标题,隐藏浮动按钮 | ||
tocToggle.style.display = 'none'; | ||
return; | ||
} | ||
|
||
const tocList = document.createElement('ul'); | ||
|
||
headings.forEach(function (heading) { | ||
if (!heading.id) { | ||
// 如果标题没有 id,生成一个 | ||
heading.id = heading.textContent.trim().toLowerCase().replace(/\s+/g, '-').replace(/[^\w\-]/g, ''); | ||
} | ||
|
||
const tocItem = document.createElement('li'); | ||
tocItem.classList.add('toc-item', heading.tagName.toLowerCase()); | ||
|
||
const tocLink = document.createElement('a'); | ||
tocLink.href = `#${heading.id}`; | ||
tocLink.textContent = heading.textContent; | ||
|
||
tocItem.appendChild(tocLink); | ||
tocList.appendChild(tocItem); | ||
}); | ||
|
||
tocContainer.appendChild(tocList); | ||
} | ||
|
||
// 页面加载时生成目录 | ||
generateTOC(); | ||
|
||
// 切换目录的显示与隐藏 | ||
tocToggle.addEventListener('click', function () { | ||
console.log("TOC toggle clicked"); // 点击按钮时输出到控制台 | ||
// 先检查当前是否是隐藏状态 | ||
if (tocContainer.classList.contains("hidden")) { | ||
tocContainer.classList.remove("hidden"); | ||
tocContainer.classList.add("visible"); | ||
} else { | ||
tocContainer.classList.remove("visible"); | ||
tocContainer.classList.add("hidden"); | ||
} | ||
}); | ||
|
||
// 点击目录项时平滑滚动到对应位置 | ||
tocContainer.addEventListener('click', function (event) { | ||
if (event.target.tagName.toLowerCase() === 'a') { | ||
event.preventDefault(); | ||
const targetId = event.target.getAttribute('href').substring(1); | ||
const targetHeading = document.getElementById(targetId); | ||
if (targetHeading) { | ||
window.scrollTo({ | ||
top: targetHeading.offsetTop - 20, // 根据需要调整偏移量 | ||
behavior: 'smooth' | ||
}); | ||
// 点击后隐藏目录 | ||
tocContainer.classList.remove("visible"); | ||
tocContainer.classList.add("hidden"); | ||
} | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.