Skip to content

Commit

Permalink
fix build failure
Browse files Browse the repository at this point in the history
  • Loading branch information
yashhere committed Jul 5, 2023
1 parent a87a3b9 commit bd42953
Show file tree
Hide file tree
Showing 9 changed files with 73 additions and 95 deletions.
2 changes: 1 addition & 1 deletion app/blog/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default async function Page({ params }: { params: { slug: string } }) {
<p>&middot;</p>
<ViewCounter slug={slug} allMetrics={allMetrics} track={true} />
<p>&middot;</p>
<Metric stat={likes} type={"likes"} />
<Metric stat={likes.toString()} type={"likes"} />
</div>
<div className="text-md mt-2 flex space-x-2 font-body font-semibold text-black/70 dark:text-white/70 sm:text-lg">
<p>Time to read: {Math.round(post.readingTime.minutes)} mins</p>
Expand Down
5 changes: 1 addition & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"@tailwindcss/typography": "^0.5.9",
"@vercel/analytics": "^1.0.1",
"clsx": "^1.2.1",
"connection-string": "^4.3.6",
"contentlayer": "^0.3.1",
"date-fns": "^2.29.3",
"framer-motion": "^10.11.2",
Expand All @@ -55,9 +54,7 @@
"reading-time": "^1.5.0",
"rss": "^1.2.2",
"shiki": "^0.14.1",
"sqlstring": "^2.3.3",
"tailwind-merge": "^1.13.2",
"undici": "^5.22.1",
"zod": "^3.21.4"
},
"devDependencies": {
Expand Down Expand Up @@ -89,7 +86,7 @@
"remark": "^14.0.3",
"remark-gfm": "^3.0.1",
"remark-math": "^5.1.1",
"tailwindcss": "^3.3.1",
"tailwindcss": "^3.3.2",
"typescript": "^5.1.0-beta"
}
}
4 changes: 1 addition & 3 deletions ui/like-button.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
"use client"

import { createHash } from "crypto"
import { getAllLikesCount, getLikes, incrementLikes } from "@/lib/actions"
import { incrementLikes } from "@/lib/actions"
import { FOCUS_VISIBLE_OUTLINE } from "@/lib/constants"
import { cn } from "@/lib/utils"
import { HeartIcon } from "@heroicons/react/24/solid"
import { headers } from "next/headers"
import { useState } from "react"

const emojis = ["👍", "🙏", "🥰"]
Expand Down
17 changes: 13 additions & 4 deletions ui/metrics/metric.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,22 @@
"use client"

import { Suspense } from "react"
import { LoadingDots } from "../loading"

export const Metric = ({
stat,
type,
}: {
stat: Number | undefined
stat: string | undefined
type: string
}) => {
return (
<span className="-mx-0.5 animate-[mutation_2s_ease-in-out_1] rounded-md px-0.5 slashed-zero tabular-nums tracking-tight">
{`${Number(stat || 0).toLocaleString()}`} {type}
</span>
<div className="flex space-x-1">
<Suspense fallback={<LoadingDots />}>
<span className="-mx-0.5 animate-[mutation_2s_ease-in-out_1] rounded-md px-0.5 slashed-zero tabular-nums tracking-tight">
{`${Number(stat || 0).toLocaleString()}`} {type}
</span>
</Suspense>
</div>
)
}
5 changes: 2 additions & 3 deletions ui/metrics/site.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
PencilSquareIcon,
} from "@heroicons/react/24/solid"
import { allPosts } from "contentlayer/generated"
import { headers } from "next/headers"
import { Suspense } from "react"
import { LoadingMetric } from "./loading"
import { Metric } from "./metric"
Expand All @@ -19,7 +18,7 @@ export const SiteMetrics = async (): Promise<JSX.Element> => {
<ArrowTrendingUpIcon className="w-5" />
<div className="flex space-x-1">
<Suspense fallback={<LoadingMetric />}>
<Metric stat={data} />
<Metric stat={data.toString()} type={"views"} />
</Suspense>
<p>views</p>
</div>
Expand All @@ -29,7 +28,7 @@ export const SiteMetrics = async (): Promise<JSX.Element> => {
<PencilSquareIcon className="w-5" />
<div className="flex space-x-1">
<Suspense fallback={<LoadingMetric />}>
<Metric stat={count} />
<Metric stat={count.toString()} type={"posts"} />
</Suspense>
<p>articles</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions ui/post/preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ export const PostPreview = ({
<div className="flex space-x-2 text-sm font-medium text-black/60 dark:text-white/60">
<p>{moment(post.published).fromNow()}</p>
<p>&middot;</p>
<Metric stat={views} type="views" />
<Metric stat={views.toString()} type="views" />
<p>&middot;</p>
<Metric stat={likes} type="likes" />
<Metric stat={likes.toString()} type="likes" />
</div>
</div>
</Link>
Expand Down
4 changes: 2 additions & 2 deletions ui/post/top-posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ export async function TopPosts() {
<div className="text-md flex space-x-2 font-medium text-black/60 dark:text-white/60">
<p>{moment(item.post.published).fromNow()}</p>
<p>&middot;</p>
<Metric stat={item.views} type="views" />
<Metric stat={item.views.toString()} type="views" />
<p>&middot;</p>
<Metric stat={item.likes} type="likes" />
<Metric stat={item.likes.toString()} type="likes" />
</div>
</div>
</div>
Expand Down
9 changes: 1 addition & 8 deletions ui/view-counter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,12 @@ export function ViewCounter({
}) {
const metrics = allMetrics && allMetrics.find((view) => view.slug === slug)
const views = new Number(metrics?.views || 0)
const likes = new Number(metrics?.likes || 0)

useEffect(() => {
if (track) {
incrementSlugMetrics(slug)
}
}, [])

return (
<div className="flex space-x-1">
<Suspense fallback={<LoadingDots />}>
<Metric stat={views} type={"views"} />
</Suspense>
</div>
)
return <Metric stat={views.toString()} type={"views"} />
}
Loading

0 comments on commit bd42953

Please sign in to comment.