Skip to content

Commit 6600596

Browse files
feat(Nostr): Meta tags, comment and image from document definition
1 parent 1cadd5b commit 6600596

1 file changed

Lines changed: 32 additions & 6 deletions

File tree

src/views/Export/Nostr.vue

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,8 @@ export default {
313313
customMessage: "",
314314
tags: ["liascript", "education"],
315315
newTag: "",
316+
317+
imageUrl: null,
316318
publishStatus: null,
317319
publishedCourseUrl: "",
318320
@@ -345,6 +347,25 @@ export default {
345347
this.privateKey = savedPrivateKey;
346348
}
347349
350+
const database = new Dexie();
351+
database
352+
.get(this.storageId)
353+
.then((meta: any) => {
354+
if (meta) {
355+
this.customMessage = meta.meta.macro.comment || "";
356+
this.imageUrl = meta.meta.macro.image || null;
357+
this.tags = meta.meta.macro.tags?.split(",").map((tag) => tag.trim()) || [
358+
"liascript",
359+
"education",
360+
];
361+
} else {
362+
console.warn("No metadata found for this course.");
363+
}
364+
})
365+
.catch((error) => {
366+
console.error("Error loading metadata:", error);
367+
});
368+
348369
// Load saved relays
349370
this.loadSavedRelays();
350371
},
@@ -632,17 +653,22 @@ export default {
632653
}
633654
634655
const title = metaData?.title || "LiaScript Course";
656+
let tags = [
657+
["d", this.storageId],
658+
["title", title],
659+
["summary", this.customMessage || "LiaScript course material"],
660+
...this.tags.map((tag) => ["t", tag]),
661+
];
662+
663+
if (this.imageUrl) {
664+
tags.push(["image", this.imageUrl]);
665+
}
635666
636667
const event = {
637668
kind: 30023,
638669
pubkey: pubkey,
639670
created_at: Math.floor(Date.now() / 1000),
640-
tags: [
641-
["d", this.storageId],
642-
["title", title],
643-
["summary", metaData?.description || "LiaScript course material"],
644-
...this.tags.map((tag) => ["t", tag]),
645-
],
671+
tags,
646672
content: contentData,
647673
};
648674

0 commit comments

Comments
 (0)