feat: 更新单个代码片段展示页面,添加编辑和删除按钮,并优化展示样式

This commit is contained in:
ngc2207 2024-11-12 15:41:57 +08:00
parent 8b251a3ea1
commit e4d639e77c

View File

@ -8,7 +8,7 @@ interface SnippetShowPageProps {
}
export default async function SnippetShowPage(props: SnippetShowPageProps) {
await new Promise((r) => setTimeout(r, 2000));
// await new Promise((r) => setTimeout(r, 2000));
const params = await props.params;
const snippet = await db.snippet.findFirst({
@ -21,5 +21,18 @@ export default async function SnippetShowPage(props: SnippetShowPageProps) {
return notFound();
}
return <div>Show a snippet: {snippet.title}</div>;
return (
<div>
<div className="flex m-4 justify-between items-center">
<h1 className="text-xl font-bold">{snippet.title}</h1>
<div className="flex gap-4">
<button className="p-2 border rounded">Edit</button>
<button className="p-2 border rounded">Delete</button>
</div>
</div>
<pre className="p-3 border rounded bg-gray-200 border-gray-200">
<code>{snippet.code}</code>
</pre>
</div>
);
}