WIP Nostr links

This commit is contained in:
2024-10-25 01:10:15 +02:00
parent 6ec9f51d77
commit eadc40392a
9 changed files with 82 additions and 23 deletions

View File

@@ -1,6 +1,7 @@
import { render as renderMarkdown } from "@deno/gfm";
import { nip19 } from "@nostr/tools";
import { NostrEvent as NEvent } from "@nostrify/nostrify";
import { replaceNostrUris } from "../nostr.ts";
import config from "../config.ts";
export default class Article {
@@ -47,10 +48,6 @@ export default class Article {
return this.event.created_at;
}
get html(): string {
return renderMarkdown(this.event.content);
}
get naddr(): string {
return nip19.naddrEncode({
identifier: this.identifier,
@@ -59,4 +56,11 @@ export default class Article {
relays: [config.relay_urls[0]],
});
}
async buildContentHtml(): Promise<string> {
let md = this.event.content.trim();
md = md.replace(`# ${this.title}\n`, "");
md = await replaceNostrUris(md);
return renderMarkdown(md);
}
}