diff --git a/src/components/LikeButton.tsx b/src/components/LikeButton.tsx deleted file mode 100644 index 50fd75b51..000000000 --- a/src/components/LikeButton.tsx +++ /dev/null @@ -1,90 +0,0 @@ -import {trpc} from '@/app/_trpc/client' -import {useViewer} from '@/context/viewer-context' -import {cn} from '@/ui/utils' -import {ThumbsUp} from 'lucide-react' -import {useEffect, useState} from 'react' - -interface LikeButtonProps { - postId: number - className?: string -} - -export function LikeButton({postId, className}: LikeButtonProps) { - const utils = trpc.useUtils() - const [mounted, setMounted] = useState(false) - const [optimisticLiked, setOptimisticLiked] = useState(false) - const [optimisticCount, setOptimisticCount] = useState(null) - const {authenticated, loading: viewerLoading} = useViewer() - - const { - data: likeCount, - isLoading: countLoading, - status: countStatus, - } = trpc.likes.getLikesForPost.useQuery({postId}) - const { - data: hasLiked, - isLoading: likedLoading, - status: likedStatus, - } = trpc.likes.hasUserLikedPost.useQuery({postId}) - - const {mutate: toggleLike, isLoading: mutationLoading} = - trpc.likes.toggleLike.useMutation({ - onMutate: () => { - setOptimisticLiked(!optimisticLiked) - setOptimisticCount((prev) => - prev !== null ? (optimisticLiked ? prev - 1 : prev + 1) : null, - ) - }, - onSettled: () => { - utils.likes.getLikesForPost.invalidate({postId}) - utils.likes.hasUserLikedPost.invalidate({postId}) - }, - onError: () => { - setOptimisticLiked(!optimisticLiked) - setOptimisticCount((prev) => - prev !== null ? (optimisticLiked ? prev + 1 : prev - 1) : null, - ) - }, - }) - - useEffect(() => { - setMounted(true) - }, []) - - useEffect(() => { - if (hasLiked !== undefined) setOptimisticLiked(hasLiked) - }, [hasLiked]) - - useEffect(() => { - if (likeCount !== undefined) setOptimisticCount(likeCount) - }, [likeCount]) - - const isLoading = - countStatus !== 'success' || likedStatus !== 'success' || viewerLoading - - return ( - - ) -} diff --git a/src/components/copy-resource.tsx b/src/components/copy-resource.tsx index faaa29876..a82940a9c 100644 --- a/src/components/copy-resource.tsx +++ b/src/components/copy-resource.tsx @@ -22,7 +22,7 @@ const CopyToClipboard: FunctionComponent< + ) +} diff --git a/src/components/share-bluesky.tsx b/src/components/share-bluesky.tsx index 5e34d91e7..8d653447f 100644 --- a/src/components/share-bluesky.tsx +++ b/src/components/share-bluesky.tsx @@ -24,7 +24,7 @@ const BlueskyLink: FunctionComponent> = ({ } return get(resource, 'title') && get(resource, 'path') ? ( > = ({ return get(resource, 'title') && get(resource, 'path') ? ( + /> ) diff --git a/src/pages/[post].tsx b/src/pages/[post].tsx index 2a0e71f15..bae9b0b10 100644 --- a/src/pages/[post].tsx +++ b/src/pages/[post].tsx @@ -24,7 +24,7 @@ import Link from 'next/link' import TweetResource from '@/components/tweet-resource' import CopyToClipboard from '@/components/copy-resource' import {track} from '@/utils/analytics' -import {LikeButton} from '@/components/LikeButton' +import {LikeButton} from '@/components/like-button' import BlueskyLink from '@/components/share-bluesky' const access: ConnectionOptions = { @@ -241,13 +241,17 @@ function InstructorProfile({ Instructor -

{instructor.full_name}

+

+ {instructor.full_name} +

) return instructor.path ? ( - {content} + + {content} + ) : ( content ) @@ -300,25 +304,10 @@ export default function PostPage({ }} /> {videoResource && ( -
-
-
-
- -
-
-
-
+ )}
{post.fields.state === 'draft' && ( @@ -328,76 +317,82 @@ export default function PostPage({

)} -
-

+
+

{post.fields.title}

-
-
+
+
+
-
-
- -
+
+ {post.fields.github && ( + { + track('clicked view source code', { + resource: post.fields.slug, + resourceType: 'post', + }) + }} + > + Code + + )}
-
- -
- {post.fields.github && ( - - Code - - )} -
- Share with a coworker -

Social Share Links

-
- - - -
+
+
+ +
+
+ Share with a coworker +
+ + +
{videoResource && (
-

Transcript

- +

+ Transcript +

+ {videoResource.fields.transcript}
)} +
@@ -417,8 +412,9 @@ function GitHubIcon() { return ( <> ) } @@ -570,7 +567,7 @@ function PodcastLinks() { const TagList = ({ tags, resourceSlug, - className = 'flex justify-center md:justify-start flex-wrap items-center', + className, }: { tags: any resourceSlug: string @@ -579,9 +576,14 @@ const TagList = ({ return ( <> {!isEmpty(tags) && ( -
    +
      {tags.map((tag: any, index: number) => ( -
    • +
    • { @@ -616,3 +618,32 @@ const TagList = ({ ) } + +const PoweredByMuxBadge = () => { + return ( + + + + + + + + + + + + ) +}