This commit is contained in:
		
							
								
								
									
										37
									
								
								src/app/blog/[[...tag]]/ActionButtons.tsx
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								src/app/blog/[[...tag]]/ActionButtons.tsx
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,37 @@ | ||||
| "use client"; | ||||
|  | ||||
| import { useRouter } from "next/navigation"; | ||||
|  | ||||
| export default function ActionButtons({ loggedIn }: { loggedIn: boolean }) { | ||||
|   const router = useRouter(); | ||||
|   return loggedIn ? ( | ||||
|     <div | ||||
|       style={{ | ||||
|         marginTop: "2rem", | ||||
|         padding: "0.5rem 1rem", | ||||
|         backgroundColor: "#333", | ||||
|         width: "fit-content", | ||||
|         userSelect: "none", | ||||
|         cursor: "pointer", | ||||
|       }} | ||||
|       onClick={() => router.push("/blog/write")} | ||||
|     > | ||||
|       write a post | ||||
|     </div> | ||||
|   ) : ( | ||||
|     <div | ||||
|       style={{ | ||||
|         marginTop: "2rem", | ||||
|         padding: "0.3rem 0.5rem", | ||||
|         backgroundColor: "#333", | ||||
|         width: "fit-content", | ||||
|         userSelect: "none", | ||||
|         cursor: "pointer", | ||||
|         fontSize: "0.8rem", | ||||
|       }} | ||||
|       onClick={() => router.push("/blog/login")} | ||||
|     > | ||||
|       login | ||||
|     </div> | ||||
|   ); | ||||
| } | ||||
| @@ -191,36 +191,6 @@ export default function PostSummary({ | ||||
|           </span> | ||||
|         </div> | ||||
|       </div> | ||||
|       {loggedIn ? ( | ||||
|         <div | ||||
|           style={{ | ||||
|             marginTop: "2rem", | ||||
|             padding: "0.5rem 1rem", | ||||
|             backgroundColor: "#333", | ||||
|             width: "fit-content", | ||||
|             userSelect: "none", | ||||
|             cursor: "pointer", | ||||
|           }} | ||||
|           onClick={() => router.push("/blog/write")} | ||||
|         > | ||||
|           write a post | ||||
|         </div> | ||||
|       ) : ( | ||||
|         <div | ||||
|           style={{ | ||||
|             marginTop: "2rem", | ||||
|             padding: "0.3rem 0.5rem", | ||||
|             backgroundColor: "#333", | ||||
|             width: "fit-content", | ||||
|             userSelect: "none", | ||||
|             cursor: "pointer", | ||||
|             fontSize: "0.8rem", | ||||
|           }} | ||||
|           onClick={() => router.push("/blog/login")} | ||||
|         > | ||||
|           login | ||||
|         </div> | ||||
|       )} | ||||
|     </> | ||||
|   ); | ||||
| } | ||||
|   | ||||
| @@ -8,6 +8,7 @@ import PostSummary from "./PostSummary"; | ||||
| import Pagination from "./Pagination"; | ||||
| import TagOverview from "./TagOverview"; | ||||
| import { isLoggedIn } from "@/components/auth"; | ||||
| import ActionButtons from "./ActionButtons"; | ||||
|  | ||||
| export default async function Blog({ | ||||
|   params, | ||||
| @@ -52,6 +53,7 @@ export default async function Blog({ | ||||
|           <PostSummary metadata={m} key={m.slug} loggedIn={loggedIn} /> | ||||
|         ))} | ||||
|       <Pagination numberOfPages={numberOfPages} pageNumber={pageNumber} /> | ||||
|       <ActionButtons loggedIn={loggedIn} /> | ||||
|     </> | ||||
|   ); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user