Skip to content

Commit

Permalink
fix: add preview in title + dont show preview post on next/previous a…
Browse files Browse the repository at this point in the history
…rticle page
  • Loading branch information
ridhozhr10 committed Jul 4, 2024
1 parent 063f796 commit 3564ad1
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/app/_components/BlogPost/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down Expand Up @@ -88,7 +90,7 @@ export default function BlogPost({
</div>
<h1 className="text-4xl mb-5 mt-12 font-bold">
<Link href="" className="no-underline">
{post.title}
{isPreview ? "PREVIEW: " :""}{post.title}
</Link>
</h1>
{post.excerpt && <div className="post-excerpt">{post.excerpt}</div>}
Expand Down
2 changes: 1 addition & 1 deletion src/app/posts/[...path]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export default async function Post({ params }: Props) {
return (
<BaseLayout logoText="cat ./content.txt | less ">
<main className="post">
<BlogPost {...post} content={content} pagination={pagination} />
<BlogPost {...post} content={content} pagination={pagination} isPreview={post.preview} />
</main>
</BaseLayout>
);
Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/post.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type Post = {
preview?: boolean;
preview: boolean;
path: string[];

created_at: string;
Expand Down
2 changes: 1 addition & 1 deletion src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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("/"));
Expand Down

0 comments on commit 3564ad1

Please sign in to comment.