hexo-blog-deploy/js/comments.js

33 lines
1.1 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* global CONFIG */
window.addEventListener('tabs:register', () => {
let { activeClass } = CONFIG.comments;
if (CONFIG.comments.storage) {
activeClass = localStorage.getItem('comments_active') || activeClass;
}
if (activeClass) {
const activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
if (activeTab) {
activeTab.click();
}
}
});
if (CONFIG.comments.storage) {
window.addEventListener('tabs:click', event => {
if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
const commentClass = event.target.classList[1];
localStorage.setItem('comments_active', commentClass);
});
}
// 首先获取所有菜单的超链接
let menus = document.querySelectorAll(".site-nav a");
// // 遍历这些超链接对象
// for (let menu of menus) {
// // 找到想要操作的超链接对象。例如我在分类页面添加了自定义JS想要排除分类页面
// if (menu.getAttribute("href")==="/tags/") {
// // 修改这个超链接对象的属性值
// menu.setAttribute("data-pjax-state", "unload");
// }
// }