alpha
Login
or
Join now
jack.is
/
leaflet
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
a tool for shared writing and social publishing
Star
0
Fork
0
Atom
Configure Feed
Issues
Pull Requests
Commits
Tags
Feed URL
Select the types of activity you want to include in your feed.
Overview
Issues
Pulls
Pipelines
support canvas titles on homepage
author
Jared Pereira
date
8 months ago
(Nov 25, 2025, 12:15 AM -0500)
commit
5ee7a1ae
5ee7a1ae811dedfdb06cb2d6972a7ee395cdec91
parent
6e3be6af
6e3be6af0d36247b63584d3aa8176049df114ae6
+25
-4
1 changed file
Expand all
Collapse all
Unified
Split
app
api
rpc
[command]
getFactsFromHomeLeaflets.ts
+25
-4
app/api/rpc/[command]/getFactsFromHomeLeaflets.ts
View file
Reviewed
···
4
4
import { makeRoute } from "../lib";
5
5
import type { Env } from "./route";
6
6
import { scanIndexLocal } from "src/replicache/utils";
7
7
-
import { getBlocksWithTypeLocal } from "src/hooks/queries/useBlocks";
8
7
import * as base64 from "base64-js";
9
8
import { YJSFragmentToString } from "components/Blocks/TextBlock/RenderYJSFragment";
10
9
import { applyUpdate, Doc } from "yjs";
···
35
34
let scan = scanIndexLocal(facts[token]);
36
35
let [root] = scan.eav(token, "root/page");
37
36
let rootEntity = root?.data.value || token;
38
38
-
let [title] = getBlocksWithTypeLocal(facts[token], rootEntity).filter(
39
39
-
(b) => b.type === "text" || b.type === "heading",
40
40
-
);
37
37
+
38
38
+
// Check page type to determine which blocks to look up
39
39
+
let [pageType] = scan.eav(rootEntity, "page/type");
40
40
+
let isCanvas = pageType?.data.value === "canvas";
41
41
+
42
42
+
// Get blocks and sort by position
43
43
+
let rawBlocks = isCanvas
44
44
+
? scan.eav(rootEntity, "canvas/block").sort((a, b) => {
45
45
+
if (a.data.position.y === b.data.position.y)
46
46
+
return a.data.position.x - b.data.position.x;
47
47
+
return a.data.position.y - b.data.position.y;
48
48
+
})
49
49
+
: scan.eav(rootEntity, "card/block").sort((a, b) => a.data.position - b.data.position);
50
50
+
51
51
+
// Map to get type and filter for text/heading
52
52
+
let blocks = rawBlocks
53
53
+
.map((b) => {
54
54
+
let type = scan.eav(b.data.value, "block/type")[0];
55
55
+
if (!type || (type.data.value !== "text" && type.data.value !== "heading")) return null;
56
56
+
return b.data;
57
57
+
})
58
58
+
.filter((b) => b !== null);
59
59
+
60
60
+
let title = blocks[0];
61
61
+
41
62
if (!title) titles[token] = "Untitled";
42
63
else {
43
64
let [content] = scan.eav(title.value, "block/text");