forked from silverbulletmd/silverbullet-plug-template
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathutils.ts
23 lines (20 loc) · 803 Bytes
/
utils.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import { readSetting } from "$sb/lib/settings_page.ts";
import { editor } from "$sb/silverbullet-syscall/mod.ts";
export async function readGraphviewSettings(key: string) {
const graphviewSettings = await readSetting("graphview", {});
if (graphviewSettings[key] !== undefined) {
return graphviewSettings[key];
}
return false;
}
// use internal navigation via syscall to prevent reloading the full page.
// From https://github.com/Willyfrog/silverbullet-backlinks
export async function navigateTo(pageRef: string) {
if (pageRef.length === 0) {
console.log("no page name supplied, ignoring navigation");
return;
}
const [page, pos] = pageRef.split("@");
console.log(`navigating to ${pageRef}`);
await editor.navigate(page, +pos); // todo: do we have the position for it?
}