"use client"; // ONE POST, DRAWN: its author and time, its words, its captured screenshot // and media, its links and its footer. The body of the post viewer // (PostModal.tsx, which re-exports everything here), in a file of its own so // a page that shows posts with no modal and no query client around them // (umtool's Posts library) draws a post exactly as the viewer does. import { useMemo } from "react"; import type { Post } from "../lib/posts"; import { pageCaptureView } from "../lib/waybackPages/view"; import { PageCaptureFacts } from "./PageCaptureFacts"; export function formatWhen(iso: string): string { const ms = Date.parse(iso); if (!Number.isFinite(ms)) return iso; const d = new Date(ms); return d.toLocaleString(undefined, { year: "numeric", month: "short", day: "numeric", hour: "2-digit", minute: "2-digit", }); } // A post's capture (a screenshot and its attached media, taken by the // editor's capture-posts job), as the page that renders this modal serves it. // EDITOR-ONLY: the files live beside the channel (`posts-media//`) and are // never published, so the export never passes `loadCapture` and never shows // any of this. export type PostCaptureView = { capturedAt: string; // The capture's state ("captured", "deleted", …), as recorded. state: string; // The post sat behind a sensitive-media cover when it was shot. sensitive?: boolean; shot?: { src: string }; media: { src: string; name: string }[]; // The X Article the post links to, when the capture opened it: its title, // how that went, and its markdown when saved. article?: { state: string; title?: string; md?: { src: string } }; }; export function PostBody({ post, primary = false, compact = false, capture, }: { post: Post; primary?: boolean; compact?: boolean; capture?: PostCaptureView | null; }) { const links = useMemo(() => post.links ?? [], [post.links]); const capturedMedia = capture?.media.length ?? 0; // A page record (a Wayback capture, release 37 S4): what the capture is, // and the original named as possibly gone beside the Wayback copy. const page = useMemo(() => pageCaptureView(post), [post]); return (
{post.authorName || post.author} {post.authorName && @{post.author}} · {post.isRepost && repost} {/* Every forum post after the first answers the thread; the badge would be on all of them. Its place in the thread says more. */} {post.isReply && !post.forum && reply} {post.forum?.position && #{post.forum.position}} {post.forum?.editedAt && ( edited )} {/* The whole point of archiving: this post no longer exists upstream. */} {post.isDeleted && ( deleted )}

{post.text}

{capture && } {page && !compact && } {post.forum?.threadTitle && !compact && (

In thread: {post.forum.threadTitle} {post.forum.page ? ` · page ${post.forum.page}` : ""}

)} {post.media && post.media.length > 0 && !capturedMedia && (
    {post.media.map((m) => (
  • {m.kind} {m.provider ? ` (${m.provider})` : ""}:{" "} {/^https?:\/\//.test(m.url) ? ( {m.name || m.url} ) : ( {m.name || m.url} )}
  • ))}
)} {links.length > 0 && ( )}
); } function Badge({ children }: { children: React.ReactNode }) { return ( {children} ); } // What a captured file is, by its extension. export function captureMediaKind(name: string): "image" | "video" | "other" { const ext = name.toLowerCase().split(".").pop() ?? ""; if (["jpg", "jpeg", "png", "gif", "webp", "avif"].includes(ext)) return "image"; if (["mp4", "webm", "mov", "m4v"].includes(ext)) return "video"; return "other"; } // The captured screenshot and media of one post, and a line for its article. // Nothing when the capture holds none of them (a deleted post's record, say). export function PostCapturePanel({ capture }: { capture: PostCaptureView }) { const { article } = capture; if (!capture.shot && capture.media.length === 0 && !article) return null; return (

Captured {formatWhen(capture.capturedAt)} {capture.sensitive ? " · behind a sensitive-media cover" : ""}

{article && (

Article: {article.title ?? "untitled"} {article.state !== "captured" ? ` (${article.state})` : ""} {article.md && ( <> {" · "} article.md )}

)} {capture.shot && ( Screenshot of the post as captured )} {capture.media.length > 0 && ( )}
); }