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
27
pulls
pipelines
add description metadata
awarm.space
2 years ago
78378f3b
ffabfe7d
+16
-4
1 changed file
expand all
collapse all
unified
split
app
[doc_id]
page.tsx
+16
-4
app/[doc_id]/page.tsx
···
86
86
.sort((a, b) => (a.position > b.position ? 1 : -1))
87
87
.filter((b) => b.type === "text" || b.type === "heading");
88
88
89
89
-
let metadata: Metadata = { title: "Untitled Leaflet", description: "" };
90
90
-
let firstBlock = blocks[0];
91
91
-
if (firstBlock?.type === "heading") {
89
89
+
let metadata: Metadata = { title: "Untitled Leaflet", description: " " };
90
90
+
let block = blocks[0];
91
91
+
if (block?.type === "heading") {
92
92
let content = initialFacts.find(
93
93
-
(f) => f.entity === firstBlock.value && f.attribute === "block/text",
93
93
+
(f) => f.entity === block.value && f.attribute === "block/text",
94
94
) as Fact<"block/text"> | undefined;
95
95
if (content) {
96
96
let doc = new Y.Doc();
···
99
99
let nodes = doc.getXmlElement("prosemirror").toArray();
100
100
metadata.title = YJSFragmentToString(nodes[0]);
101
101
}
102
102
+
block = blocks[1];
102
103
}
104
104
+
let content = initialFacts.find(
105
105
+
(f) => f.entity === block.value && f.attribute === "block/text",
106
106
+
) as Fact<"block/text"> | undefined;
107
107
+
if (content) {
108
108
+
let doc = new Y.Doc();
109
109
+
const update = base64.toByteArray(content.data.value);
110
110
+
Y.applyUpdate(doc, update);
111
111
+
let nodes = doc.getXmlElement("prosemirror").toArray();
112
112
+
metadata.description = YJSFragmentToString(nodes[0]);
113
113
+
}
114
114
+
103
115
return metadata;
104
116
}