feat: 添加代码片段编辑页面,并在展示页面中添加编辑链接

This commit is contained in:
ngc2207 2024-11-12 15:47:49 +08:00
parent e4d639e77c
commit 2478f1a91e
2 changed files with 18 additions and 1 deletions

View File

@ -0,0 +1,11 @@
interface SnippetEditPageProps {
params: Promise<{
id: string;
}>;
}
export default async function SnippetEditPage(props: SnippetEditPageProps) {
const params = await props.params;
const id = parseInt(params.id);
return <div>Editing snippet with id {id}</div>;
}

View File

@ -1,4 +1,5 @@
import { db } from "@/db"; import { db } from "@/db";
import Link from "next/link";
import { notFound } from "next/navigation"; import { notFound } from "next/navigation";
interface SnippetShowPageProps { interface SnippetShowPageProps {
@ -26,7 +27,12 @@ export default async function SnippetShowPage(props: SnippetShowPageProps) {
<div className="flex m-4 justify-between items-center"> <div className="flex m-4 justify-between items-center">
<h1 className="text-xl font-bold">{snippet.title}</h1> <h1 className="text-xl font-bold">{snippet.title}</h1>
<div className="flex gap-4"> <div className="flex gap-4">
<button className="p-2 border rounded">Edit</button> <Link
href={`/snippets/${snippet.id}/edit`}
className="p-2 border rounded"
>
Edit
</Link>
<button className="p-2 border rounded">Delete</button> <button className="p-2 border rounded">Delete</button>
</div> </div>
</div> </div>