forked from silverbulletmd/silverbullet-plug-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathgraphignore.ts
More file actions
32 lines (26 loc) · 922 Bytes
/
graphignore.ts
File metadata and controls
32 lines (26 loc) · 922 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { editor, space, index } from "$sb/silverbullet-syscall/mod.ts";
export class GraphIgnore {
ignoredPages: string[]
constructor(ignoredPages: string[] = []) {
this.ignoredPages = ignoredPages;
}
// Get all pages tagged with .graphignore
async init(): Promise<void> {
this.ignoredPages = (await index.queryPrefix("tag:.graphignore"))
.map((tag) => tag.page)
}
// Check if a page is tagged with .graphignore
isIgnoredPage(page: string): boolean {
return this.ignoredPages.includes(page);
}
// Filter function to remove pages tagged with .graphignore
pagefilter = (page) => !this.isIgnoredPage(page.name);
// Filter function to remove links to and from pages tagged with .graphignore
linkfilter = (link) => {
const topage = link.key.split(':')
.slice(1, -1)
.join(':')
return !this.isIgnoredPage(link.page)
&& !this.isIgnoredPage(topage)
}
}