1
mirror of https://github.com/jakejarvis/jarv.is.git synced 2026-06-19 12:55:28 -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:
2026-01-28 13:35:16 -05:00
parent 29487e6d5f
commit 5fc9efb181
22 changed files with 297 additions and 532 deletions
+14
View File
@@ -4,3 +4,17 @@ import { twMerge } from "tailwind-merge";
export const cn = (...inputs: ClassValue[]) => {
return twMerge(clsx(inputs));
};
/**
* Recursively extracts plain text content from React nodes.
* Replacement for the `react-to-text` package.
*/
export const getTextContent = (node: React.ReactNode): string => {
if (node == null || typeof node === "boolean") return "";
if (typeof node === "string" || typeof node === "number") return String(node);
if (Array.isArray(node)) return node.map(getTextContent).join("");
if (typeof node === "object" && "props" in node) {
return getTextContent((node as React.ReactElement<{ children?: React.ReactNode }>).props.children);
}
return "";
};