Skip to content

Commit e3064f2

Browse files
committed
context undefined fix
1 parent db7604c commit e3064f2

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

src/postman.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,25 @@ import { TextNode, TreeNode, ViewType } from "roamjs-components/types/native";
1212
import { getParseInline } from "roamjs-components/marked";
1313
import { syncParseRoamBlocksToHtml } from "roamjs-components/dom/parseRoamBlocksToHtml";
1414
import createTagRegex from "roamjs-components/util/createTagRegex";
15+
import getTextByBlockUid from "roamjs-components/queries/getTextByBlockUid";
16+
import getPageTitleByBlockUid from "roamjs-components/queries/getPageTitleByBlockUid";
17+
18+
const getRoamUrl = (blockUid?: string): string =>
19+
`${window.location.href.replace(/\/page\/.*$/, "")}${
20+
blockUid ? `/page/${blockUid}` : ""
21+
}`;
22+
23+
const context = {
24+
pagesToHrefs: (page: string, ref?: string) =>
25+
ref ? getRoamUrl(ref) : getRoamUrl(getPageUidByPageTitle(page)),
26+
blockReferences: (ref: string) => ({
27+
text: getTextByBlockUid(ref),
28+
page: getPageTitleByBlockUid(ref),
29+
}),
30+
components: (): false => {
31+
return false;
32+
},
33+
};
1534

1635
export const getParseRoamBlocks = (): Promise<
1736
(a: { content: TreeNode[]; viewType: ViewType }) => string

0 commit comments

Comments
 (0)