Add OG and Twitter Card markup, generate OG profile images

closes #2
This commit is contained in:
2024-10-24 14:19:37 +02:00
parent d5793d47ff
commit fdd16d8236
10 changed files with 182 additions and 20 deletions

View File

@@ -28,6 +28,11 @@ export default class Article {
return tag ? tag[1] : "Untitled";
}
get image(): string {
const tag = this.event.tags.find((t) => t[0] === "image");
return tag ? tag[1] : undefined;
}
get summary(): string {
const tag = this.event.tags.find((t) => t[0] === "summary");
return tag ? tag[1] : "";

View File

@@ -1,5 +1,5 @@
import { nip19, NostrEvent as NEvent } from "@nostr/tools";
// import { NEvent } from "../nostr.ts";
import config from "../config.ts";
export interface ProfileData {
name?: string;
@@ -54,4 +54,12 @@ export default class Profile {
get npub(): string {
return nip19.npubEncode(this.pubkey);
}
get profileUrl(): string {
return `${config.base_url}/@${this.username}`;
}
get ogImageUrl(): string {
return `${config.base_url}/assets/g/img/og-p-${this.event.id}.png`;
}
}