mirror of
https://github.com/jakejarvis/jarv.is.git
synced 2026-06-19 12:15:27 -04:00
fix: don't pre-render view and comment count components
- Introduced a new PostStats component to handle view and comment counts, replacing the previous async implementation with a client-side approach. - Updated CommentCount component to use client-side state management for fetching comment counts. - Removed unnecessary caching logic from view and comment fetching functions. - Simplified date formatting by moving it inline, enhancing performance and readability.
This commit is contained in:
@@ -1,11 +1,18 @@
|
||||
"use client";
|
||||
|
||||
import TimeAgo from "react-timeago";
|
||||
import { makeIntlFormatter } from "react-timeago/defaultFormatter";
|
||||
|
||||
const intlFormatter = makeIntlFormatter({
|
||||
locale: "en",
|
||||
style: "long",
|
||||
numeric: "auto",
|
||||
});
|
||||
|
||||
const RelativeTime = ({ ...rest }: React.ComponentProps<typeof TimeAgo>) => {
|
||||
return (
|
||||
<span suppressHydrationWarning>
|
||||
<TimeAgo {...rest} />
|
||||
<TimeAgo formatter={intlFormatter} {...rest} />
|
||||
</span>
|
||||
);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user