Skip to content

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

Closed
@Achuan-2

Description

@Achuan-2

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

Activity

OpaqueGlass

OpaqueGlass commented on Aug 6, 2024

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

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

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

image

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

Achuan-2 commented on Aug 6, 2024

@Achuan-2
Author
  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

Achuan-2 commented on Aug 6, 2024

@Achuan-2
Author

其他建议:

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

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

Achuan-2

Achuan-2 commented on Aug 6, 2024

@Achuan-2
Author

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

added this to the backlog milestone on Aug 6, 2024
OpaqueGlass

OpaqueGlass commented on Aug 16, 2024

@OpaqueGlass
Owner
Achuan-2

Achuan-2 commented on Aug 17, 2024

@Achuan-2
Author

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

OpaqueGlass

OpaqueGlass commented on Aug 18, 2024

@OpaqueGlass
Owner

ok😋

modified the milestones: backlog, v1.3.0 on Aug 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @OpaqueGlass@Achuan-2

        Issue actions

          反链能支持排除dailynote笔记嘛 · Issue #64 · OpaqueGlass/syplugin-hierarchyNavigate