/** * @copyright nhcarrigan * @license Naomi's Public License * @author Naomi Carrigan */ import { actionIcons, platformIcons } from "../config/icons.js"; import { landingHtml } from "../config/landing.js"; import type { App } from "../interfaces/app.js"; /** * Generates the HTML for the landing page. * @param app - The application instance. * @returns An HTML string. */ export const generateHtml = (app: App): string => { const sanctions = app.sanctions.toSorted((a, b) => { return b.number - a.number; }); const sanctionHtml = sanctions.map((sanction) => { return sanction.revoked && sanction.revokedBy !== null && sanction.revokeDate !== null && sanction.revokeReason !== null ? `
${ actionIcons.revoked ?? "" } #${sanction.number.toString()}: ${sanction.action} - REVOKED ${ platformIcons[sanction.platform.toLowerCase()] ?? "" }

${sanction.uuid}

${sanction.reason}

Performed by: ${sanction.moderator} on ${sanction.date.toLocaleString("en-GB")}

Revoked:

${sanction.revokeReason}

Revoked by: ${ sanction.revokedBy } on ${sanction.revokeDate.toLocaleString("en-GB")}

` : `
${ actionIcons[sanction.action.toLowerCase()] ?? "" } #${sanction.number.toString()}: ${sanction.action} ${ platformIcons[sanction.platform.toLowerCase()] ?? "" }

${sanction.uuid}

${sanction.reason}

Performed by: ${sanction.moderator} on ${sanction.date.toLocaleString("en-GB")}

`; }); const html = landingHtml. replace("{{ logs }}", sanctionHtml.join("\n")). replace("{{ timestamp }}", app.cacheUpdated.toLocaleString("en-GB")); return html; };