import { BRAND_COLOR, STATIC_IMAGES_URL, TRANSFORMS } from "@hey/data/constants"; import escapeHtml from "@hey/helpers/escapeHtml"; import getAvatar from "@hey/helpers/getAvatar"; import normalizeDescription from "@hey/helpers/normalizeDescription"; import { GroupDocument, type GroupFragment } from "@hey/indexer"; import type { Context } from "hono"; import { html } from "hono/html"; import generateOg from "./ogUtils"; const getGroup = async (ctx: Context) => { const { address } = ctx.req.param(); return generateOg({ buildHtml: (group: GroupFragment) => { const name = group.metadata?.name || "Group"; const title = `${name} on Hey`; const description = normalizeDescription( group?.metadata?.description, title ); const avatar = getAvatar(group, TRANSFORMS.AVATAR_BIG); const escTitle = escapeHtml(title); const escDescription = escapeHtml(description); const escName = escapeHtml(name); return html` ${escTitle} ${escTitle}

${escName}

${escDescription}

`; }, ctx, extractData: (data) => data.group as GroupFragment | null, query: GroupDocument, variables: { request: { group: address } } }); }; export default getGroup;