💾 Archived View for iich.space › src › views › PostItem.ts captured on 2022-03-01 at 16:00:32.
⬅️ Previous capture (2021-12-03)
-=-=-=-=-=-=-
import { Template } from '@/mission-control'; import { Post } from '~/db/models'; import { getLinks, sanitize } from '~/util/comments'; import { generateIdentityHash } from '~/util/identity'; import { timeAgo } from '~/util/time'; interface Props { post: Post; showLinks?: boolean; } const Name: Template<{ post: Post }> = ({ t }, { post }) => post.author || (post.fingerprint ? `!${generateIdentityHash(post.fingerprint)}` : t('anonymous')); const PostItem: Template<Props> = ( { each, include, link, t, when }, { post, showLinks }, ) => ` ${include(Name, { post })} · ${timeAgo( t, new Date(post.createdAt).getTime(), )} · ${t('no_n', post.id)} ${when( post.image !== null && showLinks, () => ` ${link(`/images/${post.image}.png`)} ${sanitize(post.comment)}`, () => ` ${sanitize(post.comment)} `, )} ${when(showLinks, () => each( getLinks(post.comment).slice(0, 3), (url) => ` ${link(url)}`, 0, ), )} `; export default PostItem;