Skip to content

Commit 69a7f76

Browse files
committed
Add Follower Component
1 parent 96958a1 commit 69a7f76

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
// BotKit by Fedify: A framework for creating ActivityPub bots
2+
// Copyright (C) 2025 Hong Minhee <https://hongminhee.org/>
3+
//
4+
// This program is free software: you can redistribute it and/or modify
5+
// it under the terms of the GNU Affero General Public License as
6+
// published by the Free Software Foundation, either version 3 of the
7+
// License, or (at your option) any later version.
8+
//
9+
// This program is distributed in the hope that it will be useful,
10+
// but WITHOUT ANY WARRANTY; without even the implied warranty of
11+
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12+
// GNU Affero General Public License for more details.
13+
//
14+
// You should have received a copy of the GNU Affero General Public License
15+
// along with this program. If not, see <https://www.gnu.org/licenses/>.
16+
/** @jsx react-jsx */
17+
/** @jsxImportSource hono/jsx */
18+
import { type Actor, getActorHandle, Link } from "@fedify/fedify/vocab";
19+
import type { Session } from "../session.ts";
20+
21+
export interface FollowerProps {
22+
readonly actor: Actor;
23+
readonly session: Session<unknown>;
24+
}
25+
26+
export async function Follower({ actor, session }: FollowerProps) {
27+
const { context } = session;
28+
const author = actor;
29+
const authorIcon = await actor?.getIcon({
30+
documentLoader: context.documentLoader,
31+
contextLoader: context.contextLoader,
32+
suppressError: true,
33+
});
34+
const authorHandle = await getActorHandle(author);
35+
36+
return (
37+
<article>
38+
<header>
39+
{author?.id
40+
? (
41+
<hgroup>
42+
{authorIcon?.url && (
43+
<img
44+
src={authorIcon.url instanceof Link
45+
? authorIcon.url.href?.href
46+
: authorIcon.url.href}
47+
width={authorIcon.width ?? undefined}
48+
height={authorIcon.height ?? undefined}
49+
alt={authorIcon.name?.toString() ?? undefined}
50+
style="float: left; margin-right: 1em; height: 64px;"
51+
/>
52+
)}
53+
<h3>
54+
<a href={author.url?.href?.toString() ?? author.id.href}>
55+
{author.name}
56+
</a>
57+
</h3>{" "}
58+
<p>
59+
<span style="user-select: all;">{authorHandle}</span>
60+
</p>
61+
</hgroup>
62+
)
63+
: <em>(Deleted account)</em>}
64+
</header>
65+
</article>
66+
);
67+
}

0 commit comments

Comments
 (0)