Compare commits
No commits in common. "2eb60f12a037a43a8fe89fa949d9c832edbe08dc" and "59422c5f6755ede474b7cca762a5f1bfd985c4b8" have entirely different histories.
2eb60f12a0
...
59422c5f67
@ -146,34 +146,13 @@ export default function PostDisplay({
|
|||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
justifyContent: "space-between",
|
justifyContent: "flex-end",
|
||||||
marginTop: "1rem",
|
marginTop: "1rem",
|
||||||
}}
|
|
||||||
>
|
|
||||||
{loggedIn ? (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
backgroundColor: "#a66",
|
|
||||||
color: "#111",
|
|
||||||
fontSize: "0.8rem",
|
|
||||||
padding: "0.5rem",
|
|
||||||
transition: "background-color 0.3s linear",
|
|
||||||
userSelect: "none",
|
userSelect: "none",
|
||||||
cursor: "pointer",
|
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
|
<span
|
||||||
style={{
|
style={{
|
||||||
backgroundColor: "#999",
|
backgroundColor: "#999",
|
||||||
@ -181,8 +160,6 @@ export default function PostDisplay({
|
|||||||
fontSize: "0.8rem",
|
fontSize: "0.8rem",
|
||||||
padding: "0.5rem",
|
padding: "0.5rem",
|
||||||
transition: "background-color 0.3s linear",
|
transition: "background-color 0.3s linear",
|
||||||
userSelect: "none",
|
|
||||||
cursor: "pointer",
|
|
||||||
}}
|
}}
|
||||||
onMouseOver={(e) => {
|
onMouseOver={(e) => {
|
||||||
e.currentTarget.style.backgroundColor = "#eee";
|
e.currentTarget.style.backgroundColor = "#eee";
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import { notFound, redirect } from "next/navigation";
|
import { notFound, redirect } from "next/navigation";
|
||||||
|
import { getPost } from "../../action";
|
||||||
import { Post } from "../../types";
|
import { Post } from "../../types";
|
||||||
import Write from "../Write";
|
import Write from "../Write";
|
||||||
import { isLoggedIn } from "@/components/auth";
|
import { isLoggedIn } from "@/components/auth";
|
||||||
import { PrismaClient } from "@prisma/client";
|
|
||||||
|
|
||||||
export default async function WritePage({
|
export default async function WritePage({
|
||||||
params,
|
params,
|
||||||
@ -16,20 +16,10 @@ export default async function WritePage({
|
|||||||
const slug = (await params).slug?.[0];
|
const slug = (await params).slug?.[0];
|
||||||
let post: Post | undefined = undefined;
|
let post: Post | undefined = undefined;
|
||||||
if (slug) {
|
if (slug) {
|
||||||
const prisma = new PrismaClient();
|
post = (await getPost(slug)) ?? undefined;
|
||||||
const result =
|
if (post == null) {
|
||||||
(await prisma.post.findUnique({
|
|
||||||
where: { slug },
|
|
||||||
include: { tags: true },
|
|
||||||
})) ?? undefined;
|
|
||||||
if (result == null) {
|
|
||||||
notFound();
|
notFound();
|
||||||
}
|
}
|
||||||
post = {
|
|
||||||
...result,
|
|
||||||
tags: result.tags.map((tag) => tag.name),
|
|
||||||
contentRendered: result.contentRendered as { __html: string },
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
return <Write post={post} />;
|
return <Write post={post} />;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user