generated from nhcarrigan/template
feat: initial app prototype
This commit is contained in:
42
src/modules/generateHtml.ts
Normal file
42
src/modules/generateHtml.ts
Normal file
@ -0,0 +1,42 @@
|
||||
/**
|
||||
* @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
|
||||
? `<div class="sanction revoked">
|
||||
<details>
|
||||
<summary>${actionIcons.revoked ?? ""} #${sanction.number.toString()}: ${sanction.action} - REVOKED ${platformIcons[sanction.platform.toLowerCase()] ?? "<i class=\"fa-solid fa-question\"></i>"}</summary>
|
||||
<p class="user">${sanction.uuid}</p>
|
||||
<p>${sanction.reason}</p>
|
||||
<p class="user">Revoked:</p>
|
||||
<p>${sanction.revokeReason ?? "Undocumented."}</p>
|
||||
</details>
|
||||
</div>
|
||||
`
|
||||
: `<div class="sanction ${sanction.action.toLowerCase()}">
|
||||
<details>
|
||||
<summary>${actionIcons[sanction.action.toLowerCase()] ?? ""} #${sanction.number.toString()}: ${sanction.action} ${platformIcons[sanction.platform.toLowerCase()] ?? "<i class=\"fa-solid fa-question\"></i>"}</summary>
|
||||
<p class="user">${sanction.uuid}</p>
|
||||
<p>${sanction.reason}</p>
|
||||
</details>
|
||||
</div>
|
||||
`;
|
||||
});
|
||||
const html = landingHtml.replace("{{ logs }}", sanctionHtml.join("\n"));
|
||||
return html;
|
||||
};
|
Reference in New Issue
Block a user