Skip to content

Commit 0b5eaa7

Browse files
authored
Merge pull request #134 from CodeForStartup/feat/improve-home-page
feat/improve home page
2 parents 9e8b531 + ac94b08 commit 0b5eaa7

File tree

22 files changed

+100
-249
lines changed

22 files changed

+100
-249
lines changed

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,16 +42,16 @@ turbo dev
4242
🚀 Turborepo
4343
🎯 TailwindCSS
4444
🔥 shadcn
45-
💌 next-themes
46-
🖋 Zod validation
47-
🎰 React Form Hook
45+
💌 next-themes
46+
🖋 Zod validation
47+
🎰 React Form Hook
4848
️🥇 Tsup
4949
💒 EditorJs
5050
🐢 react-toastify
5151
🍾 react-textarea-autosize
5252
🐠 lucide-react icon
5353
🐴 dayjs
54-
🤗 Eslint
54+
🤗 Eslint
5555
💥 Husky
5656
👽 Prettier
5757

apps/web/@/actions/protect/postAction.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ import APP_ROUTES from "@/constants/routes"
1818
import { TUserItem, userSelect } from "@/types/users"
1919
import { getServerSession } from "@/utils/auth"
2020

21+
// TODO: move to database package
22+
// Get total actions (like, bookmark) for a post
2123
export const getTotalActions = async ({
2224
postId,
2325
actionType,

apps/web/@/actions/protect/posts.ts

Lines changed: 0 additions & 45 deletions
This file was deleted.

apps/web/@/molecules/home/filter/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
import React, { useState } from "react"
44
import { usePathname, useRouter, useSearchParams } from "next/navigation"
55

6+
import { FilterValues, PeriodValues } from "database"
67
import { cn } from "ui"
78

8-
import { FilterValues, PeriodValues } from "@/types/filter"
99
import { capitalizeFirstLetter } from "@/utils/text"
1010

1111
import { FilterItem } from "./filter-item"

apps/web/@/molecules/posts/post-item/bookmark-button/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import React from "react"
22

3-
import { PostOnUserType } from "database"
3+
import { PostOnUserType, TPostItem } from "database"
44

55
import { getTotalActions } from "@/actions/protect/postAction"
6-
import { TPostItem } from "@/types/posts"
76

87
import BookmarkButton from "./BookmarkButton"
98

apps/web/@/molecules/posts/post-item/comment-button/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import React from "react"
22
import Link from "next/link"
33

4+
import { TPostItem } from "database"
45
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "ui"
56

67
import APP_ROUTES from "@/constants/routes"
7-
import { TPostItem } from "@/types/posts"
88
import { generatePath } from "@/utils/generatePath"
99

1010
type CommentButtonProps = {

apps/web/@/molecules/posts/post-item/index.tsx

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
1+
import Image from "next/image"
12
import Link from "next/link"
23

4+
import { TPostItem } from "database"
5+
import { useTranslations } from "next-intl"
36
import { Typography } from "ui"
47

58
import APP_ROUTES from "@/constants/routes"
69
import TagList from "@/molecules/tag/tag-list"
7-
import { TPostItem } from "@/types/posts"
810
import { generatePath } from "@/utils/generatePath"
911

1012
import BookmarkButton from "./bookmark-button"
@@ -13,6 +15,8 @@ import LikeButton from "./like-button"
1315
import PostMeta from "./post-meta"
1416

1517
export default function PostItem({ post }: { post: TPostItem }) {
18+
const t = useTranslations("common")
19+
1620
return (
1721
<div className="mb-4 flex rounded-sm border px-8 py-4">
1822
<div className="flex-1">
@@ -25,7 +29,7 @@ export default function PostItem({ post }: { post: TPostItem }) {
2529
variant="h2"
2630
className="hover:underline"
2731
>
28-
{post.title}
32+
{post.title || t("untitled")}
2933
</Typography>
3034
</Link>
3135

@@ -43,9 +47,19 @@ export default function PostItem({ post }: { post: TPostItem }) {
4347
<LikeButton post={post} />
4448
<CommentButton post={post} />
4549
</div>
46-
<BookmarkButton post={post} />
4750
</div>
4851
</div>
52+
{post.Image && (
53+
<div className="flex items-center">
54+
<Image
55+
src={post.Image.url}
56+
alt={post.title}
57+
width={160}
58+
height={120}
59+
className="h-[120px] w-[160px] rounded-sm object-cover"
60+
/>
61+
</div>
62+
)}
4963
</div>
5064
)
5165
}

apps/web/@/molecules/posts/post-item/like-button/index.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1+
import { TPostItem } from "database"
12
import { useTranslations } from "next-intl"
23
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger, Typography } from "ui"
34

4-
import { TPostItem } from "@/types/posts"
5-
65
type LikeButtonProps = {
76
post: TPostItem
87
}

apps/web/@/molecules/posts/post-item/post-meta/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
import React from "react"
22
import Link from "next/link"
33

4+
import { TPostItem } from "database"
45
import dayjs from "dayjs"
56

67
import APP_ROUTES from "@/constants/routes"
7-
import { TPostItem } from "@/types/posts"
88
import { generatePath } from "@/utils/generatePath"
99

1010
type PostMetaProps = {
1111
post: TPostItem
1212
}
1313

1414
const PostMeta: React.FC<PostMetaProps> = ({ post }) => {
15+
if (!post?.author) return null
16+
1517
return (
1618
<div className="mt-2 flex items-center gap-2 text-xs text-gray-400">
1719
<div className="text hover:underline">

apps/web/@/molecules/top-tags/NumberIndex.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import React from "react"
44

5-
import { useTheme } from "next-themes"
65
import { cn } from "ui"
76

87
import { bebasNeue } from "@/font"
@@ -12,12 +11,11 @@ interface NumberIndexProps {
1211
}
1312

1413
const NumberIndex: React.FC<NumberIndexProps> = ({ number }) => {
15-
// const { theme } = useTheme()
16-
1714
return (
1815
<div
1916
className={cn(
20-
"flex items-center justify-center stroke-black stroke-1 text-2xl font-extrabold"
17+
"flex items-center justify-center fill-none stroke-black stroke-1 text-2xl font-extrabold",
18+
bebasNeue.className
2119
)}
2220
>
2321
{number}.

0 commit comments

Comments
 (0)