forked from creations/profilePage
add readme support
This commit is contained in:
parent
7b30305ac8
commit
30191a5b1f
6 changed files with 176 additions and 14 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue