From 3564ad17dad6ec65d044439bd5831233eab6760d Mon Sep 17 00:00:00 2001 From: ridhozhr10 Date: Thu, 4 Jul 2024 11:30:58 +0700 Subject: [PATCH] fix: add preview in title + dont show preview post on next/previous article page --- src/app/_components/BlogPost/index.tsx | 4 +++- src/app/posts/[...path]/page.tsx | 2 +- src/interfaces/post.ts | 2 +- src/lib/api.ts | 2 +- 4 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/app/_components/BlogPost/index.tsx b/src/app/_components/BlogPost/index.tsx index e1c529a..e4a3586 100644 --- a/src/app/_components/BlogPost/index.tsx +++ b/src/app/_components/BlogPost/index.tsx @@ -28,12 +28,14 @@ import Markdown from "../Markdown"; export type BlogPostProps = Post & { content: string; + isPreview: boolean; pagination: SinglePagination; }; export default function BlogPost({ content, pagination, + isPreview, ...post }: BlogPostProps) { const shareLinks = [ @@ -88,7 +90,7 @@ export default function BlogPost({

- {post.title} + {isPreview ? "PREVIEW: " :""}{post.title}

{post.excerpt &&
{post.excerpt}
} diff --git a/src/app/posts/[...path]/page.tsx b/src/app/posts/[...path]/page.tsx index 5b2f58d..337f284 100644 --- a/src/app/posts/[...path]/page.tsx +++ b/src/app/posts/[...path]/page.tsx @@ -74,7 +74,7 @@ export default async function Post({ params }: Props) { return (
- +
); diff --git a/src/interfaces/post.ts b/src/interfaces/post.ts index 7eab981..d96e085 100644 --- a/src/interfaces/post.ts +++ b/src/interfaces/post.ts @@ -1,5 +1,5 @@ export type Post = { - preview?: boolean; + preview: boolean; path: string[]; created_at: string; diff --git a/src/lib/api.ts b/src/lib/api.ts index d643b0e..7a11852 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -97,7 +97,7 @@ export type SinglePagination = { prev?: Post; next?: Post }; export function getNextPreviousPost(post: Post): SinglePagination { const result: SinglePagination = {}; - const allPost = getAllPosts(); + const allPost = getAllPosts(false); const idxCurrent = allPost .map((d) => d.path.join("/")) .findIndex((d) => d === post.path.join("/"));