Skip to content

反链能支持排除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

Closed
Achuan-2 opened this issue Aug 6, 2024 · 7 comments
Closed

反链能支持排除dailynote笔记嘛 #64

Achuan-2 opened this issue Aug 6, 2024 · 7 comments
Milestone

Comments

@Achuan-2
Copy link

Achuan-2 commented Aug 6, 2024

我希望把面包屑的反链当成相关笔记来用,不希望包含dailynote

@OpaqueGlass
Copy link
Owner

OpaqueGlass commented Aug 6, 2024

  • 正则过滤,排除内容;(仅反向链接)
  • 排序方式;(正向链接、反向链接共用)
  • 正则匹配优先项;(仅反向链接)

--- 原内容:(或浏览编辑历史) ---

  1. 说的是这里的反链吗?

image

  1. “包含dailynote”和“当成相关笔记来用”有什么冲突?听起来不像是一个普遍需求?

Sorry, something went wrong.

@Achuan-2
Copy link
Author

Achuan-2 commented Aug 6, 2024

  1. 是的

  2. 主要用于dailynote笔记法的用户,会倾向于用moc来管理笔记,而不用文档树管理笔记,管理文档链接而不管理文档,这时候文档导航的显示父子文档就没有什么导航作用了,需要靠反链的文档来导航,显示相关文档:
    moc 文档
    Clip_2024-08-06_17-15-00

主题下的其中一个文档:由于使用dailynote积累笔记,反链有很多dailynote,但这些dailynote和这篇文档的主题无关系只有补充信息,我希望的是,反链只展示主题内容真正有关联的笔记,因此希望是可以有一个选项可以过滤掉这些dailynote的。

Clip_2024-08-06_17-14-48

@Achuan-2
Copy link
Author

Achuan-2 commented Aug 6, 2024

其他建议:

或者可以导航区域的反链显示可以自定义正则过滤也行,可以添加多个过滤规则,用户自己过滤

此外,还希望反链导航还能设置排序方式和特殊置顶规则。我一般会把moc笔记添加一个@前缀,如果有一个正则功能,可以让符合条件的文档放在最前面就很棒了,文档导航插件就不仅仅可以用于文档树分类体系,也可以用于moc笔记分类体系

@Achuan-2
Copy link
Author

Achuan-2 commented Aug 6, 2024

简单用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);

运行前
Clip_2024-08-06_17-50-01

自定义js运行后
Clip_2024-08-06_17-49-47

@OpaqueGlass
Copy link
Owner

如果可以,麻烦参与测试,谢谢:
https://github.com/OpaqueGlass/syplugin-hierarchyNavigate/releases/tag/v1.3.0-beta1

image

@Achuan-2
Copy link
Author

可以用的,谢谢!
图片:
Clip_2024-08-17_19-58-04

@OpaqueGlass
Copy link
Owner

ok😋

@OpaqueGlass OpaqueGlass modified the milestones: backlog, v1.3.0 Aug 18, 2024
@OpaqueGlass OpaqueGlass removed the stage/investigate 确认中/评估中 label Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants