mirror of
				https://litchi.icu/ngc2207/judge4c-demo.git
				synced 2025-10-30 16:44:42 +00:00 
			
		
		
		
	feat: 更新首页以支持代码片段链接和新增按钮
This commit is contained in:
		
							parent
							
								
									8a91e46c4f
								
							
						
					
					
						commit
						8b251a3ea1
					
				| @ -1,9 +1,29 @@ | |||||||
| import { db } from "@/db"; | import { db } from "@/db"; | ||||||
|  | import Link from "next/link"; | ||||||
| 
 | 
 | ||||||
| export default async function HomePage() { | export default async function HomePage() { | ||||||
|   const snippets = await db.snippet.findMany(); |   const snippets = await db.snippet.findMany(); | ||||||
|   const renderedSnippets = snippets.map((snippet) => { |   const renderedSnippets = snippets.map((snippet) => { | ||||||
|     return <div key={snippet.id}>{snippet.title}</div>; |     return ( | ||||||
|  |       <Link | ||||||
|  |         key={snippet.id} | ||||||
|  |         href={`/snippets/${snippet.id}`} | ||||||
|  |         className="flex justify-between items-center p-2 border rounded" | ||||||
|  |       > | ||||||
|  |         <div>{snippet.title}</div> | ||||||
|  |         <div>View</div> | ||||||
|  |       </Link> | ||||||
|  |     ); | ||||||
|   }); |   }); | ||||||
|   return <div>{renderedSnippets}</div>; |   return ( | ||||||
|  |     <div> | ||||||
|  |       <div className="flex m-2 justify-between items-center"> | ||||||
|  |         <h1 className="text-xl font-bold">Snippets</h1> | ||||||
|  |         <Link href="/snippets/new" className="border p-2 rounded"> | ||||||
|  |           New | ||||||
|  |         </Link> | ||||||
|  |       </div> | ||||||
|  |       <div className="flex flex-col gap-2">{renderedSnippets}</div> | ||||||
|  |     </div> | ||||||
|  |   ); | ||||||
| } | } | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user