💾 Archived View for iich.space › src › views › RecentPostItem.ts captured on 2021-12-03 at 14:04:38.

View Raw

More Information

-=-=-=-=-=-=-

import { Template } from '@/mission-control';

import { RecentPost } from '~/db/models';
import { truncate } from '~/util/truncate';

import PostItem from './PostItem';

interface Props {
  post: RecentPost;
}

const RecentPostItem: Template<Props> = ({ include }, { post }): string => {
  if (post.comment === '[Image]') {
    const replyTo = truncate(post.threadComment.split('\n')[0], 30);
    post.comment = `[Image reply in: ${replyTo}]`;
  }

  return `
=> ${post.path} ${include(PostItem, { post })}
`;
};

export default RecentPostItem;