@@ -31,6 +31,7 @@ import { decode } from "html-entities";
3131import type { BotImpl } from "./bot-impl.ts" ;
3232import { Layout } from "./components/Layout.tsx" ;
3333import { Message } from "./components/Message.tsx" ;
34+ import { Follower } from "./components/Follower.tsx" ;
3435import { getMessageClass , isMessageObject , textXss } from "./message-impl.ts" ;
3536import type { MessageClass } from "./message.ts" ;
3637import type { Uuid } from "./repository.ts" ;
@@ -142,9 +143,11 @@ app.get("/", async (c) => {
142143 </ a > { " " }
143144 ·{ " " }
144145 < span >
145- { followersCount === 1
146- ? `1 follower`
147- : `${ followersCount . toLocaleString ( "en" ) } followers` }
146+ < a href = "/followers" >
147+ { followersCount === 1
148+ ? `1 follower`
149+ : `${ followersCount . toLocaleString ( "en" ) } followers` }
150+ </ a >
148151 </ span > { " " }
149152 ·{ " " }
150153 < span >
@@ -206,6 +209,41 @@ app.get("/", async (c) => {
206209 ) ;
207210} ) ;
208211
212+ app . get ( "/followers" , async ( c ) => {
213+ const { bot } = c . env ;
214+ const ctx = bot . federation . createContext ( c . req . raw , c . env . contextData ) ;
215+ const session = bot . getSession ( ctx ) ;
216+ const followersCount = await bot . repository . countFollowers ( ) ;
217+ const followers = await Array . fromAsync ( bot . repository . getFollowers ( ) ) ;
218+
219+ const url = new URL ( c . req . url ) ;
220+ const activityLink = ctx . getActorUri ( bot . identifier ) ;
221+ const feedLink = new URL ( "/feed.xml" , url ) ;
222+
223+ return c . html (
224+ < Layout
225+ bot = { bot }
226+ host = { url . host }
227+ activityLink = { activityLink }
228+ feedLink = { feedLink }
229+ >
230+ < header class = "container" >
231+ < h1 >
232+ < a href = "/" > ←</ a > { " " }
233+ { followersCount === 1
234+ ? `1 follower`
235+ : `${ followersCount . toLocaleString ( "en" ) } followers` }
236+ </ h1 >
237+ </ header >
238+ < main class = "container" >
239+ { followers . map ( ( follower , index ) => (
240+ < Follower key = { follower . id ?. href ?? index } actor = { follower } session = { session } />
241+ ) ) }
242+ </ main >
243+ </ Layout > ,
244+ ) ;
245+ } ) ;
246+
209247app . get ( "/tags/:hashtag" , async ( c ) => {
210248 const hashtag = c . req . param ( "hashtag" ) ;
211249 const { bot } = c . env ;
0 commit comments