1616/** @jsx react-jsx */
1717/** @jsxImportSource @hono /hono/jsx */
1818import { LanguageString } from "@fedify/fedify/runtime" ;
19- import { getActorHandle , Link } from "@fedify/fedify/vocab" ;
19+ import { Document , getActorHandle , Image , Link } from "@fedify/fedify/vocab" ;
2020import type { MessageClass } from "../message.ts" ;
2121import type { Session } from "../session.ts" ;
2222
@@ -40,6 +40,7 @@ export async function Message({ session, message }: MessageProps) {
4040 suppressError : true ,
4141 } ) ;
4242 const authorHandle = author == null ? null : await getActorHandle ( author ) ;
43+ const attachments = await Array . fromAsync ( message . getAttachments ( ) ) ;
4344 return (
4445 < article >
4546 < header >
@@ -75,6 +76,25 @@ export async function Message({ session, message }: MessageProps) {
7576 ? message . content . language . compact ( )
7677 : undefined }
7778 />
79+ { attachments . length > 0 && (
80+ < div >
81+ { attachments . filter ( ( a ) =>
82+ a instanceof Image || a instanceof Document
83+ ) . filter ( ( a ) => a . mediaType ?. startsWith ( "image/" ) && a . url != null )
84+ . map ( ( a ) => (
85+ < figure >
86+ < img
87+ src = { a . url instanceof Link ? a . url . href ?. href : a . url ! . href }
88+ width = { a . width ?? undefined }
89+ height = { a . height ?? undefined }
90+ alt = { a . name ?. toString ( ) ?? undefined }
91+ style = "max-width: 75%;"
92+ />
93+ < figcaption > { a . name ?. toString ( ) } </ figcaption >
94+ </ figure >
95+ ) ) }
96+ </ div >
97+ ) }
7898 < footer >
7999 { message . published &&
80100 (
0 commit comments