tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
289
fork
atom
a tool for shared writing and social publishing
289
fork
atom
overview
issues
28
pulls
pipelines
fix sorts
awarm.space
3 months ago
94a96af9
5ee7a1ae
+11
-3
1 changed file
expand all
collapse all
unified
split
app
api
rpc
[command]
getFactsFromHomeLeaflets.ts
+11
-3
app/api/rpc/[command]/getFactsFromHomeLeaflets.ts
···
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);
49
49
+
: scan.eav(rootEntity, "card/block").sort((a, b) => {
50
50
+
if (a.data.position === b.data.position)
51
51
+
return a.id > b.id ? 1 : -1;
52
52
+
return a.data.position > b.data.position ? 1 : -1;
53
53
+
});
50
54
51
55
// Map to get type and filter for text/heading
52
56
let blocks = rawBlocks
53
57
.map((b) => {
54
58
let type = scan.eav(b.data.value, "block/type")[0];
55
55
-
if (!type || (type.data.value !== "text" && type.data.value !== "heading")) return null;
59
59
+
if (
60
60
+
!type ||
61
61
+
(type.data.value !== "text" && type.data.value !== "heading")
62
62
+
)
63
63
+
return null;
56
64
return b.data;
57
65
})
58
58
-
.filter((b) => b !== null);
66
66
+
.filter((b): b is NonNullable<typeof b> => b !== null);
59
67
60
68
let title = blocks[0];
61
69