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

@@ -5,6 +5,7 @@ import Article from "../models/article.ts";
import Profile from "../models/profile.ts";
import { articleHtml } from "../html.ts";
import notFoundHandler from "../handlers/not-found.ts";
import generateOgProfileImage from "../tasks/generate_og_profile_image.ts";
const userEventHandler = async function (ctx: Context) {
const username = ctx.state.username.replace(/^(@|~)/, "");
@@ -27,12 +28,13 @@ const userEventHandler = async function (ctx: Context) {
const article = new Article(articleEvent);
const profile = new Profile(profileEvent, username);
const html = articleHtml(article, profile);
generateOgProfileImage(profile);
ctx.response.body = html;
} else {
notFoundHandler(ctx);
}
} catch (_e) {
} catch (e) {
notFoundHandler(ctx);
}
};

View File

@@ -5,6 +5,7 @@ import Article from "../models/article.ts";
import Profile from "../models/profile.ts";
import { profilePageHtml } from "../html.ts";
import notFoundHandler from "../handlers/not-found.ts";
import generateOgProfileImage from "../tasks/generate_og_profile_image.ts";
const userProfileHandler = async function (ctx: Context) {
const username = ctx.state.path.replace(/^(@|~)/, "");
@@ -23,6 +24,7 @@ const userProfileHandler = async function (ctx: Context) {
const articleEvents = await fetchArticlesByAuthor(pubkey);
const articles = articleEvents.map((a) => new Article(a));
const html = profilePageHtml(profile, articles);
generateOgProfileImage(profile);
ctx.response.body = html;
} else {