-
Notifications
You must be signed in to change notification settings - Fork 2
反链能支持排除dailynote笔记嘛 #64
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Milestone
Comments
其他建议: 或者可以导航区域的反链显示可以自定义正则过滤也行,可以添加多个过滤规则,用户自己过滤 此外,还希望反链导航还能设置排序方式和特殊置顶规则。我一般会把moc笔记添加一个@前缀,如果有一个正则功能,可以让符合条件的文档放在最前面就很棒了,文档导航插件就不仅仅可以用于文档树分类体系,也可以用于moc笔记分类体系 |
简单用js实现了下 function filterAndReorderLinks() {
const filterPatterns = [
/^\d{8} \w{3}$/, // Example: 20240728 Sun
/^\d{6}$/,
/^\d{8} ~ \d{8}$/,
/^\d{8} \- \d{8}$/
// Add more patterns here if needed
];
const containers = document.querySelectorAll("div.og-hierachy-navigate-backlink-doc-container");
if (containers.length === 0) {
return;
}
containers.forEach(container => {
const refLinks = container.querySelectorAll("span.refLinks.docLinksWrapper");
if (refLinks.length === 0) {
return;
}
// Hide elements that match any pattern in filterPatterns
refLinks.forEach(link => {
const docName = link.getAttribute("title");
if (filterPatterns.some(pattern => pattern.test(docName))) {
link.style.display = "none";
} else {
link.style.display = ""; // Reset display property if it doesn't match
}
});
// Separate elements into two arrays: one for @-prefixed and one for otherItems
const mocItems = [];
const otherItems = [];
refLinks.forEach(link => {
const docName = link.getAttribute("title");
if (docName.startsWith("@")) {
mocItems.push(link);
} else {
otherItems.push(link);
}
});
// Sort the 'otherItems' array based on the 'title' attribute in ascending order
otherItems.sort((a, b) => {
const titleA = a.getAttribute("title").toUpperCase(); // Ignore upper and lowercase
const titleB = b.getAttribute("title").toUpperCase(); // Ignore upper and lowercase
return titleA.localeCompare(titleB);
});
// Clear only the refLinks elements and append them in the desired order
refLinks.forEach(link => link.remove());
mocItems.concat(otherItems).forEach(link => {
container.appendChild(link);
});
});
}
// Execute the function
setInterval(filterAndReorderLinks, 100); |
ok😋 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我希望把面包屑的反链当成相关笔记来用,不希望包含dailynote
The text was updated successfully, but these errors were encountered: