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/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} +
+
+ ) } 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/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 }); } } diff --git a/components/blog/comments/comment-card.tsx b/components/blog/comments/comment-card.tsx index a0742b5..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 { @@ -25,37 +25,8 @@ import { getComment } from "@/lib/prisma/get-comment"; import MarkdownCard from "@/components/markdown-card"; import { Comment } from "@prisma/client"; import { validate } from "@/lib/revalidate"; - -export function dateFormat(dateString: string | number | Date) { - const date = new Date(dateString); - const currentDate = new Date(); - - const differenceInTime = currentDate.getTime() - date.getTime(); - const differenceInDays = differenceInTime / (1000 * 3600 * 24); - - if (differenceInDays < 1) { - const differenceInHours = differenceInTime / (1000 * 3600); - if (differenceInHours < 1) { - const differenceInMinutes = differenceInTime / (1000 * 60); - if (differenceInMinutes < 1) { - const differenceInSeconds = differenceInTime / 1000; - return differenceInSeconds < 30 ? 'Just now': `${Math.floor(differenceInSeconds)}s`; - } - return `${Math.floor(differenceInMinutes)}m`; - } - return `${Math.floor(differenceInHours)}h`; - } - - if (differenceInDays > 15) { - return `${date.toLocaleDateString('en-US', { - year: 'numeric', - month: 'short', - day: 'numeric', - })}`; - } else { - return `${Math.floor(differenceInDays)}d`; - } -} +import { dateFormat } from "@/lib/format-date"; +import LoginDialog from "@/components/login-dialog"; async function fetchComment(commentId: Comment['id']) { return await getComment(commentId); @@ -99,26 +70,27 @@ export default function CommentCard({ comment: initialComment, post, session, ..
- + - + {comment.author?.name ? comment.author?.name.charAt(0) : comment.author?.username.charAt(0)} - {comment.author?.name || comment.author?.username} - {comment.author?.verified && +
+ {comment.author?.name || comment.author?.username} {comment.author?.verified && ( - )} + )} + + {dateFormat(comment.createdAt)} +
{comment.author?.id === post?.authorId && ( - Author + Author )} - · - {dateFormat(comment.createdAt)}
{ session?.id === post.authorId && ( @@ -166,21 +138,31 @@ export default function CommentCard({ comment: initialComment, post, session, .. - +
- + ) : ( + + + + ) + } {formatNumberWithSuffix(comment?._count?.likes)}
{ comment._count.replies > 0 && (
{comment?._count.replies}
@@ -188,9 +170,19 @@ export default function CommentCard({ comment: initialComment, post, session, .. }
- + ) : ( + + + + ) + }
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..2bf89d7 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,13 +94,13 @@ 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,22 +82,22 @@ export default function PostTabs({ post: initialPost, className, session, author { session ? ( ) : ( ) } - + @@ -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..4828429 100644 --- a/components/blog/post-more-actions.tsx +++ b/components/blog/post-more-actions.tsx @@ -34,10 +34,12 @@ import React from "react"; import { handleDelete } from "../delete"; import { useRouter } from "next/navigation"; import PostDeleteDialog from "./post-delete-dialog"; +import { addShare } from "@/lib/prisma/add-share"; export default function PostMoreActions({ post, session, className, children, ...props }: React.ComponentPropsWithoutRef & { post: any, session: any, className?: string }) { - const copylink = (link: string) => { + const copylink = async(link: string) => { navigator.clipboard.writeText(link) + await addShare(post?.id) } const router = useRouter() const [showDeleteAlert, setShowDeleteAlert] = React.useState(false) @@ -68,10 +70,10 @@ export default function PostMoreActions({ post, session, className, children, .. } copylink(`${process.env.DOMAIN}/@${post.author.username}/${post.url}`)}> - + Copy link - + await addShare(post?.id)}> - + await addShare(post?.id)}> @@ -92,7 +94,7 @@ export default function PostMoreActions({ post, session, className, children, ..
- + await addShare(post?.id)}>
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/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:
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/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/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/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)} 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}
) : ( diff --git a/components/navbar/navbar.tsx b/components/navbar/navbar.tsx index 6992dde..743c7aa 100644 --- a/components/navbar/navbar.tsx +++ b/components/navbar/navbar.tsx @@ -30,13 +30,13 @@ function Navbar(notifications: any) { - Beta + FalseNotes
@@ -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..6b96749 100644 --- a/components/share-list.tsx +++ b/components/share-list.tsx @@ -12,12 +12,15 @@ import { LinkedinShareButton } from 'next-share' import { Icons } from "@/components/icon"; -import { Facebook, Link2, Linkedin } from "lucide-react"; +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 ( <> @@ -25,11 +28,11 @@ export default function ShareList({ className, children, url, text, ...props }: {children} copylink(url)}> - + 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/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/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) => ( <> 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 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/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 }, }); diff --git a/package-lock.json b/package-lock.json index f19742e..3dc770d 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", @@ -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", @@ -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", @@ -8694,9 +8660,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", @@ -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", diff --git a/package.json b/package.json index 426e3c9..395ec14 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "FalseNotes", - "version": "0.2.0", + "version": "1.0.0", "private": true, "scripts": { "dev": "next dev", @@ -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", @@ -105,18 +105,6 @@ "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 + "@tailwindcss/typography": "^0.5.10" } } 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