From 039f260c60a82afa8ebedfa8228b1cdaeb2ca628 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Mon, 27 Nov 2023 21:27:09 +0900 Subject: [PATCH 01/23] Update ShareList URL in navbar.tsx --- components/blog/navbar.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/blog/navbar.tsx b/components/blog/navbar.tsx index ad70bb7..3490d6b 100644 --- a/components/blog/navbar.tsx +++ b/components/blog/navbar.tsx @@ -94,7 +94,7 @@ export default function PostTabs({ post: initialPost, className, session, author ) } - + + ) : ( + + + + ) + } {formatNumberWithSuffix(comment?._count?.likes)} { @@ -188,9 +170,19 @@ export default function CommentCard({ comment: initialComment, post, session, .. }
- + ) : ( + + + + ) + }
From bd86dc8bf0ed6c7d52d96a1e0f705e059471fc4a Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 01:23:16 +0900 Subject: [PATCH 05/23] Refactor UI icons in code --- app/(Main)/tags/page.tsx | 5 - components/blog/comments/comment-card.tsx | 8 +- components/blog/comments/delete-dialog.tsx | 3 +- components/blog/feed-post-card.tsx | 8 +- components/blog/landing-post-card.tsx | 3 +- components/blog/mobile-navbar.tsx | 38 +++--- components/blog/navbar.tsx | 17 +-- components/blog/post-more-actions.tsx | 2 +- components/explore/search.tsx | 3 +- components/explore/tab-content.tsx | 2 +- components/explore/tags.tsx | 2 +- components/icon.tsx | 137 +++++++++++++++++++-- components/navbar/navbar.tsx | 4 +- components/navbar/user-nav.tsx | 6 +- components/searchbar.tsx | 4 +- components/share-list.tsx | 2 +- components/tags/list.tsx | 3 +- components/tags/post-card-v2.tsx | 10 +- components/tags/post-card.tsx | 14 +-- components/user-hover-card.tsx | 4 +- components/user/details.tsx | 14 +-- components/user/share.tsx | 2 +- 22 files changed, 204 insertions(+), 87 deletions(-) diff --git a/app/(Main)/tags/page.tsx b/app/(Main)/tags/page.tsx index 2427395..874fedf 100644 --- a/app/(Main)/tags/page.tsx +++ b/app/(Main)/tags/page.tsx @@ -1,12 +1,7 @@ import { getSessionUser } from "@/components/get-session-user" import TagsList from "@/components/tags/list" import TagBadge from "@/components/tags/tag" -import { Badge } from "@/components/ui/badge" -import { Button } from "@/components/ui/button" -import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" -import postgres from "@/lib/postgres" import { getPopularTags, getTags } from "@/lib/prisma/tags" -import { Hash } from "lucide-react" import Link from "next/link" export default async function TagsPage() { diff --git a/components/blog/comments/comment-card.tsx b/components/blog/comments/comment-card.tsx index d129859..ac9bcbe 100644 --- a/components/blog/comments/comment-card.tsx +++ b/components/blog/comments/comment-card.tsx @@ -5,7 +5,7 @@ import { Badge } from "@/components/ui/badge"; import { Button } from "@/components/ui/button"; import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card"; import UserHoverCard from "@/components/user-hover-card"; -import { Heart, MoreHorizontal, Pencil, Reply, Trash2 } from "lucide-react"; +import { MoreHorizontal, Pencil, Reply, Trash2 } from "lucide-react"; import Markdown from "markdown-to-jsx"; import Link from "next/link"; import { @@ -146,12 +146,12 @@ export default function CommentCard({ comment: initialComment, post, session, .. { session ? ( ) : ( ) @@ -162,7 +162,7 @@ export default function CommentCard({ comment: initialComment, post, session, .. comment._count.replies > 0 && (
{comment?._count.replies}
diff --git a/components/blog/comments/delete-dialog.tsx b/components/blog/comments/delete-dialog.tsx index 550bb04..7e3c898 100644 --- a/components/blog/comments/delete-dialog.tsx +++ b/components/blog/comments/delete-dialog.tsx @@ -14,6 +14,7 @@ import { } from "@/components/ui/alert-dialog" import { Trash2 } from "lucide-react"; +import { Icons } from "@/components/icon"; export default function CommentDeleteDialog({ comment, user, ...props }: React.ComponentPropsWithoutRef & { comment: any, user: any }) { @@ -23,7 +24,7 @@ export default function CommentDeleteDialog({ comment, user, ...props }: React.C
- +

Delete Comment

diff --git a/components/blog/feed-post-card.tsx b/components/blog/feed-post-card.tsx index 4a9c0f7..079017f 100644 --- a/components/blog/feed-post-card.tsx +++ b/components/blog/feed-post-card.tsx @@ -8,7 +8,7 @@ import { BlurImage as Image } from "../image"; import { Button } from "../ui/button"; import Link from "next/link"; import { cn } from "@/lib/utils"; -import { Bookmark, MoreHorizontal } from "lucide-react"; +import { MoreHorizontal } from "lucide-react"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import UserHoverCard from "../user-hover-card"; import { Icons } from "../icon"; @@ -94,7 +94,7 @@ export default function FeedPostCard(
@@ -154,7 +154,7 @@ export default function FeedPostCard(
@@ -162,7 +162,7 @@ export default function FeedPostCard( diff --git a/components/blog/mobile-navbar.tsx b/components/blog/mobile-navbar.tsx index 1bd75a0..15432b9 100644 --- a/components/blog/mobile-navbar.tsx +++ b/components/blog/mobile-navbar.tsx @@ -13,6 +13,7 @@ import LoginDialog from "../login-dialog"; import { Separator } from "../ui/separator"; import { validate } from "@/lib/revalidate"; import { Post } from "@prisma/client"; +import { Icons } from "../icon"; export default function MobilePostTabs({ post: initialPost, className, session, author, onClicked }: { post: any, className?: string, session: any, author: any, onClicked: () => void }) { const [post, setPost] = useState(initialPost); @@ -48,15 +49,17 @@ export default function MobilePostTabs({ post: initialPost, className, session,
- { + { session ? ( ) : ( ) @@ -65,26 +68,29 @@ export default function MobilePostTabs({ post: initialPost, className, session,
- {post?._count.comments}
- { - session ? ( + { + session ? ( + + ) : ( + - ) : ( - - - - ) - } + + ) + }
{/* ) : ( @@ -68,7 +69,7 @@ export default function PostTabs({ post: initialPost, className, session, author
{post?._count.comments} @@ -81,13 +82,13 @@ export default function PostTabs({ post: initialPost, className, session, author { session ? ( ) : ( @@ -96,7 +97,7 @@ export default function PostTabs({ post: initialPost, className, session, author @@ -107,7 +108,7 @@ export default function PostTabs({ post: initialPost, className, session, author diff --git a/components/blog/post-more-actions.tsx b/components/blog/post-more-actions.tsx index a1b11ab..f04b052 100644 --- a/components/blog/post-more-actions.tsx +++ b/components/blog/post-more-actions.tsx @@ -68,7 +68,7 @@ export default function PostMoreActions({ post, session, className, children, .. } copylink(`${process.env.DOMAIN}/@${post.author.username}/${post.url}`)}> - + Copy link diff --git a/components/explore/search.tsx b/components/explore/search.tsx index b69f800..bb20287 100644 --- a/components/explore/search.tsx +++ b/components/explore/search.tsx @@ -5,6 +5,7 @@ import { Input } from "../ui/input"; import { useRouter } from "next/navigation"; import { useEffect, useRef, useState } from "react"; import { useDebounce } from 'use-debounce' +import { Icons } from "../icon"; export default function Search({search} : {search: string | undefined}) { const router = useRouter() @@ -36,7 +37,7 @@ export default function Search({search} : {search: string | undefined}) {
- +
setText(e.target.value)} placeholder="Search for people or tags" className="input__field !foucs-visible:ring-0 !focus-visible:ring-offset-0 !focus-visible:outline-none" />
diff --git a/components/explore/tab-content.tsx b/components/explore/tab-content.tsx index 31d61ca..70f1bd9 100644 --- a/components/explore/tab-content.tsx +++ b/components/explore/tab-content.tsx @@ -99,7 +99,7 @@ export default function ExploreComponent({ users, posts, tags, search, className
-

{tag.name.replace(/-/g, " ")}

+

{tag.name.replace(/-/g, " ")}

{tag._count.posts} posts · {tag._count.followingtag} followers

diff --git a/components/explore/tags.tsx b/components/explore/tags.tsx index 5daecd6..da94068 100644 --- a/components/explore/tags.tsx +++ b/components/explore/tags.tsx @@ -52,7 +52,7 @@ export default function Tags({ tags: initialTags, search, session }: { tags: any
-

{tag.name.replace(/-/g, " ")}

+

{tag.name.replace(/-/g, " ")}

{tag._count.posts} posts · {tag._count.followingtag} followers

diff --git a/components/icon.tsx b/components/icon.tsx index 3cd70e6..1406763 100644 --- a/components/icon.tsx +++ b/components/icon.tsx @@ -36,30 +36,138 @@ import { export type Icon = LucideIcon export const Icons = { - close: X, + close: (props: IconProps) => ( + + + + ), spinner: Loader2, chevronLeft: ChevronLeft, chevronRight: ChevronRight, - trash: Trash, - post: FileText, - page: File, - media: Image, - settings: Cog, - billing: CreditCard, + trash: (props: IconProps) => ( + + + + + ), + post: (props: IconProps) => ( + + + + + ), + page: (props: IconProps) => ( + + +), + media: (props: IconProps) => ( + + + + ), + settings: (props: IconProps) => ( + + + + + ), + billing: (props: IconProps) => ( + + + + + ), ellipsis: MoreVertical, add: Plus, - warning: AlertTriangle, - user: User, + warning: (props: IconProps) => ( + + + + ), + user: (props: IconProps) => ( + + + + ), arrowRight: ArrowRight, - help: HelpCircle, + help: (props: IconProps) => ( + + + + ), pizza: Pizza, sun: SunMedium, moon: Moon, laptop: Laptop, check: Check, - hash: Hash, + hash: (props: IconProps) => ( + + + + ), + logOut: (props: IconProps) => ( + + + + ), notfound: SearchX, - bookmark: Bookmark, + notification: (props: IconProps) => ( + + + + ), + share: (props: IconProps) => ( + + + + ), + bookmark: (props: IconProps) => ( + + + + + ), + like: (props: IconProps) => ( + + + + ), + commentBubble: (props: IconProps) => ( + + + + ), + moreHorizontal: (props: IconProps) => ( + + + + ), + link: (props: IconProps) => ( + + + + ), + users: (props: IconProps) => ( + + + + ), + location: (props: IconProps) => ( + + + + + ), + envelope: (props: IconProps) => ( + + + + ), + calendarDays: (props: IconProps) => ( + + + + ), logoIcon: (props: IconProps) => ( @@ -69,6 +177,11 @@ export const Icons = { + + ), + search: (props: IconProps) => ( + + ), logo: (props: IconProps) => ( diff --git a/components/navbar/navbar.tsx b/components/navbar/navbar.tsx index 28cbeb4..743c7aa 100644 --- a/components/navbar/navbar.tsx +++ b/components/navbar/navbar.tsx @@ -36,7 +36,7 @@ function Navbar(notifications: any) {
@@ -46,7 +46,7 @@ function Navbar(notifications: any) { <> diff --git a/components/navbar/user-nav.tsx b/components/navbar/user-nav.tsx index 8b9f750..e22d924 100644 --- a/components/navbar/user-nav.tsx +++ b/components/navbar/user-nav.tsx @@ -22,6 +22,7 @@ import { useEffect, useState } from "react" import { getUserByUsername } from "../get-user" import { getSessionUser } from "../get-session" import { ArrowDownRight, ArrowRight, ChevronRight, Cog, LogOut, Settings, Settings2 } from "lucide-react" +import { Icons } from "../icon" export function UserNav() { const { status } = useSession(); @@ -66,7 +67,7 @@ export function UserNav() { - + Settings @@ -74,11 +75,10 @@ export function UserNav() { - + Log out - diff --git a/components/searchbar.tsx b/components/searchbar.tsx index 626002c..244fc44 100644 --- a/components/searchbar.tsx +++ b/components/searchbar.tsx @@ -77,7 +77,7 @@ export default function SearchBar() {
- + {/* when in input clicked inter it must redirect to /explore?search=[value]*/} - + {tag.name.replace(/-/g, " ")} diff --git a/components/share-list.tsx b/components/share-list.tsx index ecc0dbd..d015546 100644 --- a/components/share-list.tsx +++ b/components/share-list.tsx @@ -25,7 +25,7 @@ export default function ShareList({ className, children, url, text, ...props }: {children} copylink(url)}> - + Copy link diff --git a/components/tags/list.tsx b/components/tags/list.tsx index ad2c846..77ff697 100644 --- a/components/tags/list.tsx +++ b/components/tags/list.tsx @@ -9,6 +9,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "../ui/card" import { cn } from "@/lib/utils" import LoginDialog from "../login-dialog"; import { validate } from "@/lib/revalidate"; +import { Icons } from "../icon"; export default function TagsList({ tags: initialTags, session, className, ...props }: { tags: any, session: any, className?: string } & React.ComponentPropsWithoutRef) { const [tags, setTags] = useState(initialTags) @@ -75,7 +76,7 @@ export default function TagsList({ tags: initialTags, session, className, ...pro
- +

{tag.name.replace(/-/g, " ")}

{tag._count.posts} posts · {tag._count.followingtag} followers

diff --git a/components/tags/post-card-v2.tsx b/components/tags/post-card-v2.tsx index 7b52541..6dbd9de 100644 --- a/components/tags/post-card-v2.tsx +++ b/components/tags/post-card-v2.tsx @@ -11,7 +11,7 @@ import { BlurImage as Image } from "../image"; import { Button } from "../ui/button"; import Link from "next/link"; import { cn } from "@/lib/utils"; -import { Bookmark, MoreHorizontal, } from "lucide-react"; +import { MoreHorizontal } from "lucide-react"; import { Badge } from "../ui/badge"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import UserHoverCard from "../user-hover-card"; @@ -118,13 +118,13 @@ export default function PostCard( { props.session ? ( ) : ( @@ -185,12 +185,12 @@ export default function PostCard( { props.session ? ( ) : ( ) diff --git a/components/tags/post-card.tsx b/components/tags/post-card.tsx index 8f88277..7d60da3 100644 --- a/components/tags/post-card.tsx +++ b/components/tags/post-card.tsx @@ -12,7 +12,7 @@ import { BlurImage as Image } from "../image"; import { Button } from "../ui/button"; import Link from "next/link"; import { cn } from "@/lib/utils"; -import { Bookmark, BookmarkPlus, CalendarDays, Check, Eye, Heart, MessageCircle, MoreHorizontal, User } from "lucide-react"; +import { MessageCircle, MoreHorizontal, User } from "lucide-react"; import { AspectRatio } from "@radix-ui/react-aspect-ratio"; import { Badge } from "../ui/badge"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; @@ -129,13 +129,13 @@ export default function TagPostCard( { props.session ? ( ) : ( @@ -146,7 +146,7 @@ export default function TagPostCard(
@@ -159,13 +159,13 @@ export default function TagPostCard( { props.session ? ( ) : ( @@ -175,7 +175,7 @@ export default function TagPostCard(
diff --git a/components/user-hover-card.tsx b/components/user-hover-card.tsx index 856d126..f817f68 100644 --- a/components/user-hover-card.tsx +++ b/components/user-hover-card.tsx @@ -61,7 +61,7 @@ export default function UserHoverCard({ user, children, className, ...props }: R {user?.bio}

- + @@ -70,7 +70,7 @@ export default function UserHoverCard({ user, children, className, ...props }: R
- {" "} + {formatDate(user?.createdAt)} diff --git a/components/user/details.tsx b/components/user/details.tsx index cce2cd9..e1555df 100644 --- a/components/user/details.tsx +++ b/components/user/details.tsx @@ -1,6 +1,6 @@ "use client"; -import { CalendarDays, Mail, MapPin, ShareIcon, Users2 } from "lucide-react"; +import { CalendarDays, Github, Mail, MapPin, ShareIcon, Users2 } from "lucide-react"; import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; import { Icons } from "../icon"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogTrigger } from "../ui/dialog"; @@ -150,14 +150,14 @@ export default function UserDetails({ className, children, user, followers, foll }
{user.bio && (
{user?.bio}
)}
- + @@ -272,7 +272,7 @@ export default function UserDetails({ className, children, user, followers, foll {user?.email &&
  • @@ -280,7 +280,7 @@ export default function UserDetails({ className, children, user, followers, foll
  • @@ -288,7 +288,7 @@ export default function UserDetails({ className, children, user, followers, foll
  • diff --git a/components/user/share.tsx b/components/user/share.tsx index a93363b..672272a 100644 --- a/components/user/share.tsx +++ b/components/user/share.tsx @@ -25,7 +25,7 @@ export default function ShareList({ className, children, url, text, ...props }: {children} copylink(url)}> - + Copy link From 41ebf59444b4009fbfb26e38587213f05f622f15 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 01:27:31 +0900 Subject: [PATCH 06/23] Fix tab styling in page and explore components --- app/(Main)/[username]/page.tsx | 6 +++--- components/explore/tab.tsx | 6 +++--- components/user/bookmark.tsx | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/app/(Main)/[username]/page.tsx b/app/(Main)/[username]/page.tsx index c186346..d269a7b 100644 --- a/app/(Main)/[username]/page.tsx +++ b/app/(Main)/[username]/page.tsx @@ -112,13 +112,13 @@ export default async function Page({ params, searchParams }: { {sessionUserName?.id === user?.id ? ( - + Posts - + Bookmarks - + Reading History diff --git a/components/explore/tab.tsx b/components/explore/tab.tsx index 860b5e6..1dc57cd 100644 --- a/components/explore/tab.tsx +++ b/components/explore/tab.tsx @@ -13,17 +13,17 @@ export default function ExploreTab({ activeTab = 'top', search }: { activeTab?: <> - + Trending - + Posts - + Users diff --git a/components/user/bookmark.tsx b/components/user/bookmark.tsx index 1528523..449864c 100644 --- a/components/user/bookmark.tsx +++ b/components/user/bookmark.tsx @@ -38,9 +38,9 @@ export default function UserBookmarks({ posts: initialPosts, className, user, se return (
    -
    +
    {posts?.length > 0 ? ( -
    +
    {posts?.map((article: any) => ( <> From 894c28e1ddc44b103ad54dea309c894f2ae452e4 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 01:27:56 +0900 Subject: [PATCH 07/23] Fix indentation in ExploreLayout component --- app/(Main)/explore/layout.tsx | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/app/(Main)/explore/layout.tsx b/app/(Main)/explore/layout.tsx index 88181b8..568bd2c 100644 --- a/app/(Main)/explore/layout.tsx +++ b/app/(Main)/explore/layout.tsx @@ -3,7 +3,7 @@ import { SiteFooter } from "@/components/footer" import { Metadata } from "next" export const metadata: Metadata = { - title: 'Explore - FalseNotes', + title: 'Explore - FalseNotes', } export default function ExploreLayout({ @@ -12,14 +12,12 @@ export default function ExploreLayout({ children: React.ReactNode }) { return ( - <> -
    -
    - {children} -
    - -
    - - + <> +
    +
    + {children} +
    +
    + ) } From 09110e655913d4a560be412c29bcf4f43b40cfb6 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 01:31:44 +0900 Subject: [PATCH 08/23] Update icons in PublishDialog component --- components/blog/publish-dialog.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/components/blog/publish-dialog.tsx b/components/blog/publish-dialog.tsx index 449d92c..81b0a19 100644 --- a/components/blog/publish-dialog.tsx +++ b/components/blog/publish-dialog.tsx @@ -75,7 +75,7 @@ export default function PublishDialog({ post, user, session, ...props }: { post:
    @@ -130,7 +130,7 @@ export default function PublishDialog({ post, user, session, ...props }: { post:
    From f135075149170b85d8d7bfcea900c3728932c0a7 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 01:56:14 +0900 Subject: [PATCH 09/23] Refactor tag filtering in feed.ts --- lib/prisma/feed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prisma/feed.ts b/lib/prisma/feed.ts index afca977..c11b6a3 100644 --- a/lib/prisma/feed.ts +++ b/lib/prisma/feed.ts @@ -161,7 +161,7 @@ const sortedTagIds = Object.entries(tagCounts) .map(([tagId]) => tagId) const posts = await postgres.post.findMany({ - where: { tags: { some: { tagId: { in: sortedTagIds.slice(0, 5) } } } }, + where: { tags: { some: { tagId: { in: sortedTagIds } } } }, select: { id: true }, }); From ade16559a48f7e32f781966956025c40fd4f8edc Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 02:26:38 +0900 Subject: [PATCH 10/23] Update build script to include next export --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 426e3c9..cb8def0 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { "name": "FalseNotes", - "version": "0.2.0", + "version": "1.0.0", "private": true, "scripts": { "dev": "next dev", - "build": "npx prisma generate && npx prisma db push && next build", + "build": "npx prisma generate && npx prisma db push && next build && next export", "start": "next start", "lint": "next lint" }, From fea4240992c8e21abcabec4c9a1ca148c5bf6dfc Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 02:30:19 +0900 Subject: [PATCH 11/23] Remove next export from build script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index cb8def0..76e6889 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "private": true, "scripts": { "dev": "next dev", - "build": "npx prisma generate && npx prisma db push && next build && next export", + "build": "npx prisma generate && npx prisma db push && next build", "start": "next start", "lint": "next lint" }, From a93e04932b83a08e26ba04f099b96fdf1c1e22e3 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 02:40:13 +0900 Subject: [PATCH 12/23] Remove unused import and handle missing post URL --- .../[username]/opengraph-image/route.tsx | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/api/posts/[username]/opengraph-image/route.tsx b/app/api/posts/[username]/opengraph-image/route.tsx index a3f1ea6..1b67a81 100644 --- a/app/api/posts/[username]/opengraph-image/route.tsx +++ b/app/api/posts/[username]/opengraph-image/route.tsx @@ -1,5 +1,4 @@ /* eslint-disable @next/next/no-img-element */ -import { Icons } from "@/components/icon"; import { ImageResponse } from "next/og"; import { NextRequest, NextResponse } from "next/server"; @@ -29,20 +28,23 @@ export async function GET(req: NextRequest, { params }: { params: { username: st regularFont, boldFont, ]); - try { - const { username } = params - const postUrl = req.nextUrl.searchParams.get("url"); - if (!postUrl) { - return NextResponse.json("Missing post url", { status: 400 }); - } + const { username } = params; + const postUrl = req.nextUrl.searchParams.get("url"); + if (!postUrl) { + return NextResponse.json("Missing post url", { status: 400 }); + } + + try { const response = await fetch(`${process.env.DOMAIN}/api/posts/${username}/${postUrl}`); + if (!response.ok) { return NextResponse.json("Error fetching user data", { status: 500 }); - } + const data = await response.json(); const post = data; + return new ImageResponse( ( post.cover ? ( @@ -136,7 +138,8 @@ export async function GET(req: NextRequest, { params }: { params: { username: st }, ); } catch (error) { - console.error(error); + console.error("Error fetching user data", error); + return NextResponse.json("Error occurred", { status: 500 }); } } From 747ef7a1fbd3aa26004cc9768a23753ae1d2ab3d Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 02:46:48 +0900 Subject: [PATCH 13/23] Update package-lock.json version --- package-lock.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index f19742e..a4ebba2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "FalseNotes", - "version": "0.2.0", + "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "FalseNotes", - "version": "0.2.0", + "version": "1.0.0", "dependencies": { "@auth/prisma-adapter": "^1.0.5", "@azure/storage-blob": "^12.17.0", @@ -8694,9 +8694,9 @@ } }, "node_modules/next-auth": { - "version": "4.24.4", - "resolved": "https://registry.npmjs.org/next-auth/-/next-auth-4.24.4.tgz", - "integrity": "sha512-5DGffi+OpkbU62vPQIJ1z+hFnmow+ec5Qrn9m6eoglIO51m0DlrmLxBduZEwKAYDEg9k2joi1yelgmq1vqK3aQ==", + "version": "4.24.5", + "resolved": "https://registry.npmjs.org/next-auth/-/next-auth-4.24.5.tgz", + "integrity": "sha512-3RafV3XbfIKk6rF6GlLE4/KxjTcuMCifqrmD+98ejFq73SRoj2rmzoca8u764977lH/Q7jo6Xu6yM+Re1Mz/Og==", "dependencies": { "@babel/runtime": "^7.20.13", "@panva/hkdf": "^1.0.2", From 714cc33eb7356616404f92f532893cb6a39b330a Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 02:51:51 +0900 Subject: [PATCH 14/23] Update next-auth version --- package-lock.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index a4ebba2..19a6e3a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,7 +63,7 @@ "multer": "^1.4.5-lts.1", "net": "^1.0.2", "next": "^14.0.3", - "next-auth": "^4.24.4", + "next-auth": "^4.24.5", "next-share": "^0.27.0", "next-themes": "^0.2.1", "nextjs-toploader": "^1.4.2", diff --git a/package.json b/package.json index 76e6889..7454ed7 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "multer": "^1.4.5-lts.1", "net": "^1.0.2", "next": "^14.0.3", - "next-auth": "^4.24.4", + "next-auth": "^4.24.5", "next-share": "^0.27.0", "next-themes": "^0.2.1", "nextjs-toploader": "^1.4.2", From 38a3e49d1ef9cb89825f17e34f9b2fe81df6f984 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 02:59:06 +0900 Subject: [PATCH 15/23] Remove unnecessary devDependencies and browser configurations --- package.json | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/package.json b/package.json index 7454ed7..f7c2722 100644 --- a/package.json +++ b/package.json @@ -103,20 +103,5 @@ "typescript": "5.2.2", "use-debounce": "^9.0.4", "zod": "^3.22.2" - }, - "devDependencies": { - "@tailwindcss/typography": "^0.5.10", - "@types/formidable": "^3.4.3", - "@types/pg": "^8.10.7", - "@types/uuid": "^9.0.4", - "dns": "file:./app/mock/dns" - }, - "browser": { - "crypto": false, - "fs": false, - "net": false, - "path": false, - "stream": false, - "tls": false } } From 01fc545965e5f4dd0f3fabcb5e26f8c84a03ed6b Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 03:03:32 +0900 Subject: [PATCH 16/23] Add @tailwindcss/typography as a dev dependency --- package.json | 3 +++ 1 file changed, 3 insertions(+) diff --git a/package.json b/package.json index f7c2722..395ec14 100644 --- a/package.json +++ b/package.json @@ -103,5 +103,8 @@ "typescript": "5.2.2", "use-debounce": "^9.0.4", "zod": "^3.22.2" + }, + "devDependencies": { + "@tailwindcss/typography": "^0.5.10" } } From 8b25b3a52909c38c0fbb71314da549f69864aeef Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 03:07:15 +0900 Subject: [PATCH 17/23] Update tag filtering in feed.ts --- lib/prisma/feed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prisma/feed.ts b/lib/prisma/feed.ts index c11b6a3..afca977 100644 --- a/lib/prisma/feed.ts +++ b/lib/prisma/feed.ts @@ -161,7 +161,7 @@ const sortedTagIds = Object.entries(tagCounts) .map(([tagId]) => tagId) const posts = await postgres.post.findMany({ - where: { tags: { some: { tagId: { in: sortedTagIds } } } }, + where: { tags: { some: { tagId: { in: sortedTagIds.slice(0, 5) } } } }, select: { id: true }, }); From ada00c02cc7b2f5014b5e0e96f128a7ee8d1dcfc Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 03:20:20 +0900 Subject: [PATCH 18/23] Refactor tag filtering in feed.ts --- lib/prisma/feed.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/prisma/feed.ts b/lib/prisma/feed.ts index afca977..c11b6a3 100644 --- a/lib/prisma/feed.ts +++ b/lib/prisma/feed.ts @@ -161,7 +161,7 @@ const sortedTagIds = Object.entries(tagCounts) .map(([tagId]) => tagId) const posts = await postgres.post.findMany({ - where: { tags: { some: { tagId: { in: sortedTagIds.slice(0, 5) } } } }, + where: { tags: { some: { tagId: { in: sortedTagIds } } } }, select: { id: true }, }); From c72fcb2c23e5131e581d556b29eb5e3c53b7dbaf Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 10:20:29 +0900 Subject: [PATCH 19/23] Add PostShare model to schema.prisma --- prisma/schema.prisma | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/prisma/schema.prisma b/prisma/schema.prisma index e54ec12..d3463cc 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -63,6 +63,7 @@ model Post { savedUsers Bookmark[] readedUsers ReadingHistory[] drafts DraftPost[] + shares PostShare[] @@index([createdAt]) @@map("posts") @@ -85,6 +86,16 @@ model DraftPost { @@map("drafts") } +model PostShare { + id String @id @default(uuid()) @map("_id") + post Post @relation(fields: [postId], references: [id]) + postId String + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + @@map("postshares") +} + model Comment { id String @id @default(cuid()) @map("_id") content String From 301cc12cd7584ec314046e085459d3c939de06dc Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 20:37:42 +0900 Subject: [PATCH 20/23] Update image scaling and hover effect --- components/blog/post.tsx | 2 +- components/image.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/components/blog/post.tsx b/components/blog/post.tsx index 4ff9fb7..378c444 100644 --- a/components/blog/post.tsx +++ b/components/blog/post.tsx @@ -77,7 +77,7 @@ export default function SinglePost({ post: initialPost, author, sessionUser, tag
    { post?.cover && ( - {post?.title} + {post?.title} ) }

    {post?.title}

    diff --git a/components/image.tsx b/components/image.tsx index 68aff42..18f6baa 100644 --- a/components/image.tsx +++ b/components/image.tsx @@ -15,7 +15,7 @@ export function BlurImage(props: ComponentProps) { alt={props.alt} className={cn( props.className, - "duration-700 ease-in-out", + "duration-700 ease-in-out hover:scale-105", isLoading ? "scale-105 blur-lg" : "scale-100 blur-0", )} onLoadingComplete={() => setLoading(false)} From ea11a91d0ea2927a311a9463c63b12569b31eb20 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 20:39:09 +0900 Subject: [PATCH 21/23] Remove unused import in share-list component --- components/share-list.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/share-list.tsx b/components/share-list.tsx index d015546..e165f5b 100644 --- a/components/share-list.tsx +++ b/components/share-list.tsx @@ -12,7 +12,7 @@ import { LinkedinShareButton } from 'next-share' import { Icons } from "@/components/icon"; -import { Facebook, Link2, Linkedin } from "lucide-react"; +import { Facebook, Linkedin } from "lucide-react"; export default function ShareList({ className, children, url, text, ...props }: React.ComponentPropsWithoutRef & { children: React.ReactNode, className?: string, url: string, text: string }) { From 522e938ed8eced3f009b2bb84b4dd7422f190629 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 20:42:05 +0900 Subject: [PATCH 22/23] Fix image className in MarkdownCard component --- components/markdown-card.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/markdown-card.tsx b/components/markdown-card.tsx index 64651bf..16d4bdc 100644 --- a/components/markdown-card.tsx +++ b/components/markdown-card.tsx @@ -13,7 +13,7 @@ export default function MarkdownCard({ code, className }: { code: string, classN component: (props: any) => { return props.title ? (
    - {props.alt} + {props.alt}
    {props.title}
    ) : ( From 1fb712b16cfec2da0838da0d47387e669a10d5a8 Mon Sep 17 00:00:00 2001 From: Bakhtiyor Ganijon Date: Tue, 28 Nov 2023 21:12:32 +0900 Subject: [PATCH 23/23] Update share functionality --- components/blog/feed-post-card.tsx | 4 +- components/blog/navbar.tsx | 2 +- components/blog/post-more-actions.tsx | 10 ++- components/share-list.tsx | 13 +-- lib/prisma/add-share.ts | 16 ++++ package-lock.json | 116 +------------------------- 6 files changed, 35 insertions(+), 126 deletions(-) create mode 100644 lib/prisma/add-share.ts diff --git a/components/blog/feed-post-card.tsx b/components/blog/feed-post-card.tsx index 079017f..2bf89d7 100644 --- a/components/blog/feed-post-card.tsx +++ b/components/blog/feed-post-card.tsx @@ -100,7 +100,7 @@ export default function FeedPostCard(
    - + await addShare(post?.id)}>
    diff --git a/components/share-list.tsx b/components/share-list.tsx index e165f5b..6b96749 100644 --- a/components/share-list.tsx +++ b/components/share-list.tsx @@ -13,11 +13,14 @@ import { } from 'next-share' import { Icons } from "@/components/icon"; import { Facebook, Linkedin } from "lucide-react"; +import { Post } from "@prisma/client"; +import { addShare } from "@/lib/prisma/add-share"; -export default function ShareList({ className, children, url, text, ...props }: React.ComponentPropsWithoutRef & { children: React.ReactNode, className?: string, url: string, text: string }) { - const copylink = (link: string) => { +export default function ShareList({ className, children, url, text, post, ...props }: React.ComponentPropsWithoutRef & { children: React.ReactNode, className?: string, url: string, text: string, post: Post['id'] }) { + const copylink = async(link: string) => { navigator.clipboard.writeText(link) + await addShare(post) } return ( <> @@ -29,7 +32,7 @@ export default function ShareList({ className, children, url, text, ...props }: Copy link - + await addShare(post)}> - + await addShare(post)}> @@ -51,7 +54,7 @@ export default function ShareList({ className, children, url, text, ...props }:
    - + await addShare(post)}>
    diff --git a/lib/prisma/add-share.ts b/lib/prisma/add-share.ts new file mode 100644 index 0000000..821c110 --- /dev/null +++ b/lib/prisma/add-share.ts @@ -0,0 +1,16 @@ +"use server"; +import { Post, PostShare } from "@prisma/client"; +import postgres from "../postgres"; + +export const addShare = async (postId: PostShare["postId"]) => { + if (!postId) return; + try { + await postgres.postShare.create({ + data: { + postId, + }, + }); + } catch (error) { + console.log(error); + } +}; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 19a6e3a..3dc770d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -104,16 +104,12 @@ "zod": "^3.22.2" }, "devDependencies": { - "@tailwindcss/typography": "^0.5.10", - "@types/formidable": "^3.4.3", - "@types/pg": "^8.10.7", - "@types/uuid": "^9.0.4", - "dns": "file:./app/mock/dns" + "@tailwindcss/typography": "^0.5.10" } }, "app/mock/dns": { "version": "3.1.0", - "dev": true + "extraneous": true }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", @@ -2856,15 +2852,6 @@ "@types/send": "*" } }, - "node_modules/@types/formidable": { - "version": "3.4.4", - "resolved": "https://registry.npmjs.org/@types/formidable/-/formidable-3.4.4.tgz", - "integrity": "sha512-0yRhMir7fdWIGfiCoYcqF6fQ2NXpb/0WwWQzg6n+K4IEIeqDVDDiDZfgfLJpi1Tbj8nvVKOAcyLVKAT3f0ZTiw==", - "dev": true, - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/hast": { "version": "2.3.7", "resolved": "https://registry.npmjs.org/@types/hast/-/hast-2.3.7.tgz", @@ -2938,17 +2925,6 @@ "resolved": "https://registry.npmjs.org/@types/nprogress/-/nprogress-0.2.2.tgz", "integrity": "sha512-2wLrSJXLztGmr7wXwM0hA/wuIOY9DznVdd+ZFofHOiXcj9JnVt+2ZeLRJ7v5ZVlmheSkUOSg3Q3O4Ce7yji79A==" }, - "node_modules/@types/pg": { - "version": "8.10.7", - "resolved": "https://registry.npmjs.org/@types/pg/-/pg-8.10.7.tgz", - "integrity": "sha512-ksJqHipwYaSEHz9e1fr6H6erjoEdNNaOxwyJgPx9bNeaqOW3iWBQgVHfpwiSAoqGzchfc+ZyRLwEfeCcyYD3uQ==", - "dev": true, - "dependencies": { - "@types/node": "*", - "pg-protocol": "*", - "pg-types": "^4.0.1" - } - }, "node_modules/@types/prop-types": { "version": "15.7.9", "resolved": "https://registry.npmjs.org/@types/prop-types/-/prop-types-15.7.9.tgz", @@ -3027,12 +3003,6 @@ "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.9.tgz", "integrity": "sha512-zC0iXxAv1C1ERURduJueYzkzZ2zaGyc+P2c95hgkikHPr3z8EdUZOlgEQ5X0DRmwDZn+hekycQnoeiiRVrmilQ==" }, - "node_modules/@types/uuid": { - "version": "9.0.6", - "resolved": "https://registry.npmjs.org/@types/uuid/-/uuid-9.0.6.tgz", - "integrity": "sha512-BT2Krtx4xaO6iwzwMFUYvWBWkV2pr37zD68Vmp1CDV196MzczBRxuEpD6Pr395HAgebC/co7hOphs53r8V7jew==", - "dev": true - }, "node_modules/@typescript-eslint/parser": { "version": "6.8.0", "resolved": "https://registry.npmjs.org/@typescript-eslint/parser/-/parser-6.8.0.tgz", @@ -4644,10 +4614,6 @@ "redux": "^4.2.0" } }, - "node_modules/dns": { - "resolved": "app/mock/dns", - "link": true - }, "node_modules/doctrine": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-3.0.0.tgz", @@ -9015,12 +8981,6 @@ "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/obuf": { - "version": "1.1.2", - "resolved": "https://registry.npmjs.org/obuf/-/obuf-1.1.2.tgz", - "integrity": "sha512-PX1wu0AmAdPqOL1mWhqmlOd8kOIZQwGZw6rh7uby9fTc5lhaOWFLX3I6R1hrF9k3zUY40e6igsLGkDXK92LJNg==", - "dev": true - }, "node_modules/oidc-token-hash": { "version": "5.0.3", "resolved": "https://registry.npmjs.org/oidc-token-hash/-/oidc-token-hash-5.0.3.tgz", @@ -9314,15 +9274,6 @@ "node": ">=4.0.0" } }, - "node_modules/pg-numeric": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/pg-numeric/-/pg-numeric-1.0.2.tgz", - "integrity": "sha512-BM/Thnrw5jm2kKLE5uJkXqqExRUY/toLHda65XgFTBTFYZyopbKjBe29Ii3RbkvlsMoFwD+tHeGaCjjv0gHlyw==", - "dev": true, - "engines": { - "node": ">=4" - } - }, "node_modules/pg-pool": { "version": "3.6.1", "resolved": "https://registry.npmjs.org/pg-pool/-/pg-pool-3.6.1.tgz", @@ -9336,24 +9287,6 @@ "resolved": "https://registry.npmjs.org/pg-protocol/-/pg-protocol-1.6.0.tgz", "integrity": "sha512-M+PDm637OY5WM307051+bsDia5Xej6d9IR4GwJse1qA1DIhiKlksvrneZOYQq42OM+spubpcNYEo2FcKQrDk+Q==" }, - "node_modules/pg-types": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-4.0.1.tgz", - "integrity": "sha512-hRCSDuLII9/LE3smys1hRHcu5QGcLs9ggT7I/TCs0IE+2Eesxi9+9RWAAwZ0yaGjxoWICF/YHLOEjydGujoJ+g==", - "dev": true, - "dependencies": { - "pg-int8": "1.0.1", - "pg-numeric": "1.0.2", - "postgres-array": "~3.0.1", - "postgres-bytea": "~3.0.0", - "postgres-date": "~2.0.1", - "postgres-interval": "^3.0.0", - "postgres-range": "^1.1.1" - }, - "engines": { - "node": ">=10" - } - }, "node_modules/pg/node_modules/pg-types": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/pg-types/-/pg-types-2.2.0.tgz", @@ -9581,51 +9514,6 @@ "resolved": "https://registry.npmjs.org/postcss-value-parser/-/postcss-value-parser-4.2.0.tgz", "integrity": "sha512-1NNCs6uurfkVbeXG4S8JFT9t19m45ICnif8zWLd5oPSZ50QnwMfK+H3jv408d4jw/7Bttv5axS5IiHoLaVNHeQ==" }, - "node_modules/postgres-array": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/postgres-array/-/postgres-array-3.0.2.tgz", - "integrity": "sha512-6faShkdFugNQCLwucjPcY5ARoW1SlbnrZjmGl0IrrqewpvxvhSLHimCVzqeuULCbG0fQv7Dtk1yDbG3xv7Veog==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/postgres-bytea": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postgres-bytea/-/postgres-bytea-3.0.0.tgz", - "integrity": "sha512-CNd4jim9RFPkObHSjVHlVrxoVQXz7quwNFpz7RY1okNNme49+sVyiTvTRobiLV548Hx/hb1BG+iE7h9493WzFw==", - "dev": true, - "dependencies": { - "obuf": "~1.1.2" - }, - "engines": { - "node": ">= 6" - } - }, - "node_modules/postgres-date": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/postgres-date/-/postgres-date-2.0.1.tgz", - "integrity": "sha512-YtMKdsDt5Ojv1wQRvUhnyDJNSr2dGIC96mQVKz7xufp07nfuFONzdaowrMHjlAzY6GDLd4f+LUHHAAM1h4MdUw==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/postgres-interval": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/postgres-interval/-/postgres-interval-3.0.0.tgz", - "integrity": "sha512-BSNDnbyZCXSxgA+1f5UU2GmwhoI0aU5yMxRGO8CdFEcY2BQF9xm/7MqKnYoM1nJDk8nONNWDk9WeSmePFhQdlw==", - "dev": true, - "engines": { - "node": ">=12" - } - }, - "node_modules/postgres-range": { - "version": "1.1.3", - "resolved": "https://registry.npmjs.org/postgres-range/-/postgres-range-1.1.3.tgz", - "integrity": "sha512-VdlZoocy5lCP0c/t66xAfclglEapXPCIVhqqJRncYpvbCgImF0w67aPKfbqUMr72tO2k5q0TdTZwCLjPTI6C9g==", - "dev": true - }, "node_modules/preact": { "version": "10.18.1", "resolved": "https://registry.npmjs.org/preact/-/preact-10.18.1.tgz",