Compare commits

..

No commits in common. "2eb60f12a037a43a8fe89fa949d9c832edbe08dc" and "59422c5f6755ede474b7cca762a5f1bfd985c4b8" have entirely different histories.

2 changed files with 7 additions and 40 deletions

View File

@ -146,34 +146,13 @@ export default function PostDisplay({
<div
style={{
display: "flex",
justifyContent: "space-between",
justifyContent: "flex-end",
marginTop: "1rem",
}}
>
{loggedIn ? (
<div
style={{
backgroundColor: "#a66",
color: "#111",
fontSize: "0.8rem",
padding: "0.5rem",
transition: "background-color 0.3s linear",
userSelect: "none",
cursor: "pointer",
backgroundColor: "transparent",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#c88";
}}
onMouseOut={(e) => {
e.currentTarget.style.backgroundColor = "#a66";
}}
onClick={() => router.push(`/blog/write/${post.slug}`)}
>
edit
</div>
) : (
<div></div>
)}
<span
style={{
backgroundColor: "#999",
@ -181,8 +160,6 @@ export default function PostDisplay({
fontSize: "0.8rem",
padding: "0.5rem",
transition: "background-color 0.3s linear",
userSelect: "none",
cursor: "pointer",
}}
onMouseOver={(e) => {
e.currentTarget.style.backgroundColor = "#eee";

View File

@ -1,8 +1,8 @@
import { notFound, redirect } from "next/navigation";
import { getPost } from "../../action";
import { Post } from "../../types";
import Write from "../Write";
import { isLoggedIn } from "@/components/auth";
import { PrismaClient } from "@prisma/client";
export default async function WritePage({
params,
@ -16,20 +16,10 @@ export default async function WritePage({
const slug = (await params).slug?.[0];
let post: Post | undefined = undefined;
if (slug) {
const prisma = new PrismaClient();
const result =
(await prisma.post.findUnique({
where: { slug },
include: { tags: true },
})) ?? undefined;
if (result == null) {
post = (await getPost(slug)) ?? undefined;
if (post == null) {
notFound();
}
post = {
...result,
tags: result.tags.map((tag) => tag.name),
contentRendered: result.contentRendered as { __html: string },
};
}
return <Write post={post} />;
}