add readme support

This commit is contained in:
creations 2025-04-05 09:18:54 -04:00
parent 7b30305ac8
commit 30191a5b1f
Signed by: creations
GPG key ID: 8F553AA4320FC711
6 changed files with 176 additions and 14 deletions

View file

@ -1,6 +1,6 @@
import { lanyardConfig } from "@config/environment";
import { renderEjsTemplate } from "@helpers/ejs";
import { getLanyardData } from "@helpers/lanyard";
import { getLanyardData, handleReadMe } from "@helpers/lanyard";
const routeDef: RouteDef = {
method: "GET",
@ -14,7 +14,7 @@ async function handler(request: ExtendedRequest): Promise<Response> {
if (!data.success) {
return await renderEjsTemplate("error", {
message: "User not found or Lanyard data unavailable.",
message: data.error.message,
});
}
@ -29,20 +29,22 @@ async function handler(request: ExtendedRequest): Promise<Response> {
}
const presence: LanyardData = data.data;
const readme: string | Promise<string> | null =
await handleReadMe(presence);
const ejsTemplateData: EjsTemplateData = {
title: "User Page",
username: presence.discord_user.username,
status: presence.discord_status,
activities: presence.activities,
user: presence.discord_user,
platform: {
desktop: presence.active_on_discord_desktop,
mobile: presence.active_on_discord_mobile,
web: presence.active_on_discord_web,
},
instance: instance,
instance,
readme,
};
return await renderEjsTemplate("index", ejsTemplateData);