56 lines
1.9 KiB
TypeScript
56 lines
1.9 KiB
TypeScript
import { escapeHtml } from "../utils/html";
|
|
import { formatUptime } from "../utils/format";
|
|
|
|
interface LayoutProps {
|
|
title: string;
|
|
content: string;
|
|
}
|
|
|
|
export function BaseLayout({ title, content }: LayoutProps): string {
|
|
const safeTitle = escapeHtml(title);
|
|
|
|
// Calculate uptime for the footer
|
|
const uptimeSeconds = process.uptime();
|
|
const startTimestamp = Date.now() - (uptimeSeconds * 1000);
|
|
const initialUptimeString = formatUptime(uptimeSeconds);
|
|
|
|
return `<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>${safeTitle} | Aurora</title>
|
|
<link rel="stylesheet" href="/style.css">
|
|
<meta name="description" content="Aurora Bot Web Interface">
|
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
|
<script src="https://unpkg.com/lucide@latest"></script>
|
|
</head>
|
|
<body>
|
|
<header>
|
|
<h1>Aurora</h1>
|
|
<nav>
|
|
<a href="/">Home</a>
|
|
<a href="/dashboard" class="active">Dashboard</a>
|
|
</nav>
|
|
</header>
|
|
<main>
|
|
${content}
|
|
</main>
|
|
<footer>
|
|
<div class="footer-content">
|
|
<p>© ${new Date().getFullYear()} Aurora</p>
|
|
<div class="footer-status">
|
|
<span class="status-indicator online"></span>
|
|
<span>Operational</span>
|
|
<span style="margin: 0 8px; color: var(--accents-2)">/</span>
|
|
<span id="uptime-display" data-start-timestamp="${Math.floor(startTimestamp)}">${initialUptimeString}</span>
|
|
</div>
|
|
</div>
|
|
</footer>
|
|
<script src="/script.js" defer></script>
|
|
</body>
|
|
</html>`;
|
|
}
|