Initial commit
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import Link from "next/link";
|
||||
import { notFound } from "next/navigation";
|
||||
|
||||
function formatTitle(slug: string) {
|
||||
return slug
|
||||
.replace(/-/g, " ")
|
||||
.replace(/\b\w/g, (c) => c.toUpperCase());
|
||||
}
|
||||
|
||||
export default async function ViewPage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ slug: string }>;
|
||||
}) {
|
||||
const { slug } = await params;
|
||||
const htmlPath = path.join(process.cwd(), "public/html", `${slug}.html`);
|
||||
|
||||
if (!fs.existsSync(htmlPath)) {
|
||||
notFound();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="min-h-screen flex flex-col bg-zinc-50 dark:bg-zinc-950">
|
||||
<header className="border-b border-zinc-200 dark:border-zinc-800 bg-white dark:bg-zinc-900 px-6 py-4 flex items-center gap-4 shrink-0">
|
||||
<Link
|
||||
href="/"
|
||||
className="text-sm text-zinc-500 hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors"
|
||||
>
|
||||
← Back
|
||||
</Link>
|
||||
<h1 className="text-lg font-semibold text-zinc-900 dark:text-zinc-100">
|
||||
{formatTitle(slug)}
|
||||
</h1>
|
||||
</header>
|
||||
<main className="flex-1">
|
||||
<iframe
|
||||
src={`/html/${slug}.html`}
|
||||
className="w-full h-[calc(100vh-65px)] border-0"
|
||||
title={formatTitle(slug)}
|
||||
/>
|
||||
</main>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user