43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
const server = Bun.serve({
|
|
port: Number(process.env.PORT ?? 4173),
|
|
async fetch(request) {
|
|
const url = new URL(request.url);
|
|
|
|
if (url.pathname === "/" || url.pathname === "/index.html") {
|
|
return new Response(
|
|
`<!doctype html>
|
|
<html lang="zh-CN">
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
<link rel="stylesheet" href="/theme-gitea-auto.css">
|
|
<title>Gitea Theme Preview</title>
|
|
</head>
|
|
<body>
|
|
<main class="page-content dashboard" style="max-width: 960px; margin: 0 auto;">
|
|
<h1>Gitea Theme Preview</h1>
|
|
<p>用于快速检查 token、primitive、component 和 page 覆盖效果。</p>
|
|
<button class="ui primary button">Primary Button</button>
|
|
<button class="ui button">Default Button</button>
|
|
<div class="ui input" style="display:block; margin-top: 1rem;">
|
|
<input type="text" value="Repository search">
|
|
</div>
|
|
</main>
|
|
</body>
|
|
</html>`,
|
|
{ headers: { "content-type": "text/html; charset=utf-8" } },
|
|
);
|
|
}
|
|
|
|
if (url.pathname === "/theme-gitea-auto.css") {
|
|
return new Response(Bun.file("dist/theme-gitea-auto.css"), {
|
|
headers: { "content-type": "text/css; charset=utf-8" },
|
|
});
|
|
}
|
|
|
|
return new Response("Not Found", { status: 404 });
|
|
},
|
|
});
|
|
|
|
console.log(`preview http://localhost:${server.port}`);
|